MCPcopy
hub / github.com/dgraph-io/dgraph / Format

Method Format

dgraph/cmd/cert/info.go:189–218  ·  view source on GitHub ↗

Format implements the fmt.Formatter interface, used by fmt functions to generate output using custom format specifiers. This function creates the format specifiers '%n', '%x', '%e' to extract name, expiration date, and error string from an Info object.

(f fmt.State, c rune)

Source from the content-addressed store, hash-verified

187// format specifiers '%n', '%x', '%e' to extract name, expiration date, and
188// error string from an Info object.
189func (i *certInfo) Format(f fmt.State, c rune) {
190 w, wok := f.Width() // width modifier. eg., %20n
191 p, pok := f.Precision() // precision modifier. eg., %.20n
192
193 var str string
194 switch c {
195 case 'n':
196 str = i.commonName
197
198 case 'x':
199 if i.expireDate.IsZero() {
200 break
201 }
202 str = i.expireDate.Format(time.RFC822)
203
204 case 'e':
205 if i.err != nil {
206 str = i.err.Error()
207 }
208 }
209
210 if wok {
211 str = fmt.Sprintf("%-[2]*[1]s", str, w)
212 }
213 if pok && len(str) < p {
214 str = str[:p]
215 }
216
217 x.Check2(f.Write([]byte(str)))
218}

Callers 15

doQueryMethod · 0.80
processQueryFunction · 0.80
runFunction · 0.80
reportOnceMethod · 0.80
printCountersMethod · 0.80
backupNameFunction · 0.80
ProcessBackupRequestFunction · 0.80
exportInternalFunction · 0.80
PrintMethod · 0.80
runLsbackupCmdFunction · 0.80

Calls 3

Check2Function · 0.92
WriteMethod · 0.65
ErrorMethod · 0.45

Tested by 2