MCPcopy Create free account
hub / github.com/antonmedv/gitmal / wrap

Function wrap

pkg/gitdiff/testdata/apply/bin.go:69–87  ·  view source on GitHub ↗
(data []byte)

Source from the content-addressed store, hash-verified

67}
68
69func wrap(data []byte) string {
70 var s strings.Builder
71 for i := 0; i < len(data); i += 52 {
72 c := 52
73 if c > len(data)-i {
74 c = len(data) - i
75 }
76 b := (c / 5) * 4
77
78 if b <= 26 {
79 s.WriteByte(byte('A' + b - 1))
80 } else {
81 s.WriteByte(byte('a' + b - 27))
82 }
83 s.Write(data[i : i+c])
84 s.WriteByte('\n')
85 }
86 return s.String()
87}
88
89func init() {
90 flag.StringVar(&mode, "mode", "parse", "operation mode, one of 'parse' or 'encode'")

Callers 1

mainFunction · 0.85

Calls 3

WriteByteMethod · 0.80
WriteMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected