Skip to content

Commit 95cb707

Browse files
authored
Merge pull request #39 from gammazero/fix-vet-warnings
Fix vet warnings about conversion of int to string
2 parents e2260b5 + 2985033 commit 95cb707

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ language: go
55

66
go:
77
- 1.11.x
8+
- 1.15.x
89

910
env:
1011
global:

multibase.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func Encode(base Encoding, data []byte) (string, error) {
8484
switch base {
8585
case Identity:
8686
// 0x00 inside a string is OK in golang and causes no problems with the length calculation.
87-
return string(Identity) + string(data), nil
87+
return string(rune(Identity)) + string(data), nil
8888
case Base2:
8989
return string(Base2) + binaryEncodeToString(data), nil
9090
case Base16:

multibase_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func TestMap(t *testing.T) {
2424

2525
var sampleBytes = []byte("Decentralize everything!!!")
2626
var encodedSamples = map[Encoding]string{
27-
Identity: string(0x00) + "Decentralize everything!!!",
27+
Identity: string(rune(0x00)) + "Decentralize everything!!!",
2828
Base2: "00100010001100101011000110110010101101110011101000111001001100001011011000110100101111010011001010010000001100101011101100110010101110010011110010111010001101000011010010110111001100111001000010010000100100001",
2929
Base16: "f446563656e7472616c697a652065766572797468696e67212121",
3030
Base16Upper: "F446563656E7472616C697A652065766572797468696E67212121",
@@ -91,22 +91,22 @@ func TestRoundTrip(t *testing.T) {
9191
continue
9292
}
9393

94-
_, _, err := Decode(string(base) + "\u00A0")
94+
_, _, err := Decode(string(rune(base)) + "\u00A0")
9595
if err == nil {
9696
t.Fatal(EncodingToStr[base] + " decode should fail on low-unicode")
9797
}
9898

99-
_, _, err = Decode(string(base) + "\u1F4A8")
99+
_, _, err = Decode(string(rune(base)) + "\u1F4A8")
100100
if err == nil {
101101
t.Fatal(EncodingToStr[base] + " decode should fail on emoji")
102102
}
103103

104-
_, _, err = Decode(string(base) + "!")
104+
_, _, err = Decode(string(rune(base)) + "!")
105105
if err == nil {
106106
t.Fatal(EncodingToStr[base] + " decode should fail on punctuation")
107107
}
108108

109-
_, _, err = Decode(string(base) + "\xA0")
109+
_, _, err = Decode(string(rune(base)) + "\xA0")
110110
if err == nil {
111111
t.Fatal(EncodingToStr[base] + " decode should fail on high-latin1")
112112
}

0 commit comments

Comments
 (0)