You're absolutely right -- and, if you'll notice, there's a TODO on the 
traceLocation.String() method 
<https://github.com/golang/glog/blob/master/glog.go#L347> to "clean this 
up".

Granted, all it needs is a:

if !t.isSet() {
  return ""
}



On Friday, November 17, 2017 at 5:27:49 PM UTC-8, Brian Kennedy wrote:
>
> 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"
>
>   "github.com/golang/glog"
> )
>
> 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)
>   }
> }
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to