Skip to content

What's different between token.Token.IdValue() and token.Token.StringValue() #95

@OhYee

Description

@OhYee

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.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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions