Home  >  Article  >  Backend Development  >  About the difference between & and * in go and its application scenarios

About the difference between & and * in go and its application scenarios

藏色散人
藏色散人forward
2021-02-22 14:14:593156browse

The following tutorial column will introduce to you the difference between go’s & and *, as well as application scenarios. I hope it will be helpful to friends in need! & In go, the address character is taken directly , but the second item returns &{} instead of 0x...Address

I don’t quite understand this

package mainimport "fmt"type Test struct {
    name string}func main() {
    test := Test{"test"}
    fmt.Println(test)
    //结果{test}

    testa := &Test{"test"}
    fmt.Println(testa)
    //结果 &{test}

    testc := &Test{"test"}
    fmt.Println(*testc)
    //结果 {test}


    testd := &Test{"test"}
    fmt.Println(&testd)
    //结果 0xc000006030}

The above is the detailed content of About the difference between & and * in go and its application scenarios. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete