MCPcopy Index your code
hub / github.com/expr-lang/expr / constructOrigFormat

Method constructOrigFormat

internal/spew/format.go:65–87  ·  view source on GitHub ↗

constructOrigFormat recreates the original format string including precision and width information to pass along to the standard fmt package. This allows automatic deferral of all format strings this package doesn't support.

(verb rune)

Source from the content-addressed store, hash-verified

63// and width information to pass along to the standard fmt package. This allows
64// automatic deferral of all format strings this package doesn't support.
65func (f *formatState) constructOrigFormat(verb rune) (format string) {
66 buf := bytes.NewBuffer(percentBytes)
67
68 for _, flag := range supportedFlags {
69 if f.fs.Flag(int(flag)) {
70 buf.WriteRune(flag)
71 }
72 }
73
74 if width, ok := f.fs.Width(); ok {
75 buf.WriteString(strconv.Itoa(width))
76 }
77
78 if precision, ok := f.fs.Precision(); ok {
79 buf.Write(precisionBytes)
80 buf.WriteString(strconv.Itoa(precision))
81 }
82
83 buf.WriteRune(verb)
84
85 format = buf.String()
86 return format
87}
88
89// unpackValue returns values inside of non-nil interfaces when possible and
90// ensures that types for values which have been unpacked from an interface

Callers 1

FormatMethod · 0.95

Calls 5

FlagMethod · 0.80
WidthMethod · 0.80
PrecisionMethod · 0.80
WriteMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected