- package main
- import(
- "fmt"
- )
- // 变量 名字 类型
- func add(a int, b int) int {
- var sum int
- sum = a + b
- return sum
- }
- func main() {
- // 调用
- var c int
- c = add(100, 200)
- fmt.Println("hello world==add=", c)
- }
- package main
- import(
- "fmt"
- )
- func test_pipe() {
- // 管道
- pipe := make(chan int,3)
- pipe <- 1
- pipe <- 2
- pipe <- 3
- fmt.Println(len(pipe))
- }
- // func main() {
- // test_pipe ()
- // // 调用
- // }
来源: http://www.bubuko.com/infodetail-3269315.html