Bug report github.com/golang/glog

78 views
Skip to first unread message

Brian Kennedy

unread,
Nov 17, 2017, 8:27:49 PM11/17/17
to golan...@googlegroups.com
For the flag "log_backtrace_at" the flag expects "" for an empty value when calling Set(), but .String() will return ":0" when the value is empty. This results in a different "emtpy" value being generated by String() than is accepted by Set().

The following code will reproduce the issue.

Output from process:
Value: ":0"
Setting flag returned error: syntax error: expect file.go:234

Code Snippet:

package main

import (
  "flag"
  "fmt"

)

func main() {
  flag.Parse()

  lba := flag.Lookup("log_backtrace_at")
  if lba == nil {
    glog.Fatalf("Needs to depend on glog")
  }
  fmt.Printf("Value: \"%s\"\n", lba.Value.String())
  err := lba.Value.Set(lba.Value.String())
  if err != nil {
    fmt.Printf("Setting flag returned error: %s\n", err)
  }
}

Tim Peoples

unread,
Nov 18, 2017, 9:18:28 PM11/18/17
to golang-nuts
You're absolutely right -- and, if you'll notice, there's a TODO on the traceLocation.String() method to "clean this up".

Granted, all it needs is a:

if !t.isSet() {
 
return ""
}
Reply all
Reply to author
Forward
0 new messages