Converting a custom type to string in Go

前端 未结 5 2072
感动是毒
感动是毒 2020-12-14 15:36

In this bizarre example, someone has created a new type which is really just a string:

type CustomType string

const (
        Foobar CustomType = \"somestr         


        
5条回答
  •  一向
    一向 (楼主)
    2020-12-14 16:17

    Convert the value to a string:

    func SomeFunction() string {
            return string(Foobar)
    }
    

提交回复
热议问题