Open OhYee opened 5 years ago
It seems that when I want to get the token's content text, I should use token.Token.IdValue() instead of token.Token.StringValue() ?
token.Token.IdValue()
token.Token.StringValue()
token.Token.StringValue() will return the string without first and last letter, and may cause panic when the length of word is 1.
For example, in the README.demo
test.go
input := []byte("hello g")
ast.go
func NewWorld(id Attrib) (*World, error) { return &World{id.(*token.Token).StringValue()}, nil }
It seems that when I want to get the token's content text, I should use
token.Token.IdValue()
instead oftoken.Token.StringValue()
?token.Token.StringValue()
will return the string without first and last letter, and may cause panic when the length of word is 1.For example, in the README.demo
test.go
ast.go