Go String after variable declaration

前端 未结 2 738
庸人自扰
庸人自扰 2021-01-21 01:55

Take a look at this snip found at here

import (
    \"encoding/xml\"
    \"fmt\"
    \"os\"
)

func main() {
    type Address struct {
        City, State string
             


        
相关标签:
2条回答
  • 2021-01-21 02:30

    It's a struct tag. Libraries use these to annotate struct fields with extra information; in this case, the module encoding/xml uses these struct tags to denote which tags correspond to the struct fields.

    0 讨论(0)
  • 2021-01-21 02:41

    which mean that variable will present in the name of Person example

    type sample struct {
         dateofbirth string `xml:"dob"`
    }
    
    In the above example, the field 'dateofbirth' will present in the name of 'dob' in the XML.
    

    you will see this notation often in go struct.

    0 讨论(0)
提交回复
热议问题