// Format formats the frame according to the fmt.Formatter interface. // // %s source file // %d source line // %n function name // %v equivalent to %s:%d // // Format accepts flags that alter the printing of some verbs, as follows: // // %+s function name and path of source file relative to the compile time // GOPATH separated by \n\t (<funcname>\n\t<path>) // %+v equivalent to %+s:%d func(f Frame)Format(state fmt.State, verb rune) { switch verb { case's': switch { case state.Flag('+'): // Flag reports whether the flag is present io.WriteString(state, f.name()) // state has the Write function -> Writer interface io.WriteString(state, "\n\t") io.WriteString(state, f.file()) default: io.WriteString(state, path.Base(f.file())) } case'd': io.WriteString(state, strconv.Itoa(f.line())) case'n': io.WriteString(state, funcname(f.name())) case'v': f.Format(state, 's') io.WriteString(s, ":") f.Format(state, 'd') } }