Standard library / go/constant
go/constant.Value
Represents an untyped constant. Kind classifies it, String gives a human-readable approximation, and ExactString gives the exact represented value. StringVal extracts unquoted string content. Private methods prevent external implementations. Expected stdout: 'Float 0.1 1/10\n'.
Formal Syntax & Structure
go syntaxgo
type Value interface { Kind() Kind
String() string
ExactString() string
}Working Example
Example Snippetgo
package main
import ( "fmt" "go/constant" "go/token")
func main() { var v constant.Value = constant.MakeFromLiteral("0.1", token.FLOAT, 0) fmt.Println(v.Kind(), v.String(), v.ExactString())}