diff --git a/_cmptest/fmtdemo/fmt.go b/_cmptest/fmtdemo/fmt.go index ac7fad13..374ab334 100644 --- a/_cmptest/fmtdemo/fmt.go +++ b/_cmptest/fmtdemo/fmt.go @@ -1,8 +1,12 @@ package main -import "fmt" +import ( + "errors" + "fmt" +) func main() { fmt.Println("Hello, world") fmt.Printf("%f\n", 3.14) + fmt.Printf("%v\n", errors.New("error message")) } diff --git a/internal/lib/fmt/print.go b/internal/lib/fmt/print.go index 702830f0..d3368b85 100644 --- a/internal/lib/fmt/print.go +++ b/internal/lib/fmt/print.go @@ -750,7 +750,6 @@ func (p *pp) printArg(arg any, verb rune) { p.fmtInteger(uint64(f), unsigned, verb) case string: p.fmtString(f, verb) - /* TODO(xsw): case []byte: p.fmtBytes(f, verb, "[]byte") case reflect.Value: @@ -763,17 +762,13 @@ func (p *pp) printArg(arg any, verb rune) { } } p.printValue(f, verb, 0) - */ default: - /* - // If the type is not simple, it might have methods. - if !p.handleMethods(verb) { - // Need to use reflection, since the type had no - // interface methods that could be used for formatting. - p.printValue(reflect.ValueOf(f), verb, 0) - } - */ - panic("todo: fmt.(*pp).printArg") + // If the type is not simple, it might have methods. + if !p.handleMethods(verb) { + // Need to use reflection, since the type had no + // interface methods that could be used for formatting. + p.printValue(reflect.ValueOf(f), verb, 0) + } } }