token.go: better implementation of the function String()
This commit is contained in:
parent
07ca84170e
commit
dda10749d0
6
token.go
6
token.go
@ -27,7 +27,11 @@ func (tk *Token) DevString() string {
|
||||
|
||||
func (tk *Token) String() string {
|
||||
if tk.Value != nil {
|
||||
return fmt.Sprintf("%#v", tk.Value)
|
||||
if s, ok := tk.Value.(string); ok {
|
||||
return fmt.Sprintf("%q", s)
|
||||
} else {
|
||||
return fmt.Sprintf("%v", tk.Value)
|
||||
}
|
||||
}
|
||||
return fmt.Sprintf("%s", tk.source)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user