<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>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # 匿名組合 ## 匿名字段 一般情況下,定義結構體的時候是字段名和其類型一一對應,實際上go支持**只提供類型而不寫字段名的方法**,也就是匿名字段,也稱為嵌入式字段 當匿名字段也是一個結構體的時候,那么這個結構體所擁有的全部字段都被隱式的引入了當前定義的這個結構體 實現代碼復用 ~~~ type Person struct { id int name string sex byte //字符類型 age int } type Student struct { Person //匿名字段,默認Student就包含了Person的所有字段 id int addr string } ~~~ ~~~ func main() { //要加結構體名字里面 s := Student{Person{11, "mm"}, 11, "aaa"} // %v詳細打印 fmt.Printf("s = %v\n", s) } ~~~ 輸出 ~~~ s = {{11 mm} 11 aaa} ~~~ ## 顯示賦值 ~~~ type Person struct { id int name string } type Student struct { Person //匿名字段,默認Student就包含了Person的所有字段 id int addr string } func main() { var s Student //默認是給本作用域,如果找不到找其他的 s.id = 1 //指定,顯示調用 s.Person.id = 2 // %v詳細打印 fmt.Printf("s = %v\n", s) } ~~~ ## 非結構體匿名字段 ~~~ type mystr string type Person struct { id int name string } type Student struct { Person //匿名字段,默認Student就包含了Person的所有字段 id int addr string mystr } func main() { var s Student //默認是給本作用域,如果找不到找其他的 s.id = 1 s.mystr = "111" //指定,顯示調用 s.Person.id = 2 // %v詳細打印 fmt.Printf("s = %v\n", s) } ~~~
                  <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>

                              哎呀哎呀视频在线观看