github.com/xyproto/u-root@v6.0.1-0.20200302025726-5528e0c77a3c+incompatible/cmds/core/elvish/eval/vals/string.go (about) 1 package vals 2 3 // Stringer wraps the String method. 4 type Stringer interface { 5 // Stringer converts the receiver to a string. 6 String() string 7 } 8 9 // ToString converts a Value to string. When the Value type implements 10 // String(), it is used. Otherwise Repr(NoPretty) is used. 11 func ToString(v interface{}) string { 12 switch v := v.(type) { 13 case Stringer: 14 return v.String() 15 case string: 16 return v 17 default: 18 return Repr(v, NoPretty) 19 } 20 }