@@ -36,7 +36,7 @@ used. For Cid version 1 the multibase prefix is included.
36
36
// documented in the FormatRef constant
37
37
func Format (fmtStr string , base mb.Encoding , cid * Cid ) (string , error ) {
38
38
p := cid .Prefix ()
39
- out := new ( bytes.Buffer )
39
+ var out bytes.Buffer
40
40
var err error
41
41
encoder , err := mb .NewEncoder (base )
42
42
if err != nil {
@@ -59,19 +59,19 @@ func Format(fmtStr string, base mb.Encoding, cid *Cid) (string, error) {
59
59
case 'B' : // base code
60
60
out .WriteByte (byte (base ))
61
61
case 'v' : // version string
62
- fmt .Fprintf (out , "cidv%d" , p .Version )
62
+ fmt .Fprintf (& out , "cidv%d" , p .Version )
63
63
case 'V' : // version num
64
- fmt .Fprintf (out , "%d" , p .Version )
64
+ fmt .Fprintf (& out , "%d" , p .Version )
65
65
case 'c' : // codec name
66
66
out .WriteString (codecToString (p .Codec ))
67
67
case 'C' : // codec code
68
- fmt .Fprintf (out , "%d" , p .Codec )
68
+ fmt .Fprintf (& out , "%d" , p .Codec )
69
69
case 'h' : // hash fun name
70
70
out .WriteString (hashToString (p .MhType ))
71
71
case 'H' : // hash fun code
72
- fmt .Fprintf (out , "%d" , p .MhType )
72
+ fmt .Fprintf (& out , "%d" , p .MhType )
73
73
case 'L' : // hash length
74
- fmt .Fprintf (out , "%d" , p .MhLength )
74
+ fmt .Fprintf (& out , "%d" , p .MhLength )
75
75
case 'm' , 'M' : // multihash encoded in base %b
76
76
out .WriteString (encode (encoder , cid .Hash (), fmtStr [i ] == 'M' ))
77
77
case 'd' , 'D' : // hash digest encoded in base %b
@@ -89,7 +89,7 @@ func Format(fmtStr string, base mb.Encoding, cid *Cid) (string, error) {
89
89
case 'S' : // cid string without base prefix
90
90
out .WriteString (encode (encoder , cid .Bytes (), true ))
91
91
case 'P' : // prefix
92
- fmt .Fprintf (out , "cidv%d-%s-%s-%d" ,
92
+ fmt .Fprintf (& out , "cidv%d-%s-%s-%d" ,
93
93
p .Version ,
94
94
codecToString (p .Codec ),
95
95
hashToString (p .MhType ),
0 commit comments