token.go: better implementation of the function String()
This commit is contained in:
@@ -27,7 +27,11 @@ func (tk *Token) DevString() string {
|
|||||||
|
|
||||||
func (tk *Token) String() string {
|
func (tk *Token) String() string {
|
||||||
if tk.Value != nil {
|
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)
|
return fmt.Sprintf("%s", tk.source)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user