<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                內置函數 1. close:主要用來關閉channel 2. len:用來求長度,比如string、array、slice、map、channel 3. new:用來分配內存,主要用來分配值類型,比如int、struct。返回的是指針 4. make:用來分配內存,主要用來分配引用類型,比如chan、map、slice 5. append:用來追加元素到數組、slice中 6. panic和recover:用來做錯誤處理 7. new和make的區別 ![](https://box.kancloud.cn/704a004b94865ecabd1b8cac989ec410_528x317.png) new 可以給任何類型變量分配內存,但不會給大小, make會分配容量,長度。 func test5(){ var a []int a = make([]int,10) a[0] = 100 fmt.Println(a) var b *[]int b = new([]int) (*b) = make([]int,10) (*b)[0] = 100 fmt.Println(b) //2 b = &a (*b)[0] = 1000 fmt.Println(a) } 詳細請參考: http://www.cnblogs.com/junneyang/p/6070238.html 函數 1. 聲明語法:func 函數名 (參數列列表) [(返回值列列表)] {} 2. 錯誤的寫法 func add() { } 3、golang函數特點: a. 不不?支持重載,?一個包不不能有兩個名字?一樣的函數 b. 函數是?一等公?民,函數也是?一種類型,?一個函數可以賦值給變量量 c. 匿匿名函數 d. 多返回值 ~~~ package main import "fmt" func add(a, b int) int { return a + b } func main() { //函數是?一等公?民,也可以和變量量?一樣進 ?行行賦值 c := add fmt.Printf("%p %T %p %T\n", c, add, c, add) sum := c(10, 20) fmt.Println(sum) sum = add(10, 20) fmt.Println(sum) } ~~~ ~~~ package main import "fmt" type add_func func(int, int) int func add(a, b int) int { return a + b } func operator(op add_func, a int, b int) int { //使?用傳進來的函數,進?行行操作 return op(a, b) } func main() { c := add fmt.Println(c) sum := operator(c, 100, 200) fmt.Println(sum) } ~~~ ~~~ package main import "fmt" type add_func func(int, int) int func add(a, b, c int) int { return a + b+c } func operator(op add_func, a int, b int) int { return op(a, b) } func main() { c := add fmt.Println(c) sum := operator(c, 100, 200) fmt.Println(sum) } ~~~ ~~~ package main import "fmt" type add_func func(int, int) int func sub(a, b int) int { return a - b } func operator(op add_func, a int, b int) int { return op(a, b) } func main() { c := sub fmt.Println(c) sum := operator(c, 100, 200) fmt.Println(sum) } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看