Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-cid
Commits
b1cc3e40
Unverified
Commit
b1cc3e40
authored
May 13, 2019
by
Steven Allen
Committed by
GitHub
May 13, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #85 from ipfs/feat/cidv1-default-base32
default cidv1 to base32
parents
e7e67e08
b16425b9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
7 deletions
+7
-7
README.md
README.md
+1
-1
cid.go
cid.go
+1
-1
cid_test.go
cid_test.go
+5
-5
No files found.
README.md
View file @
b1cc3e40
...
...
@@ -67,7 +67,7 @@ This will make sure that dependencies are rewritten to known working versions.
```
go
// Create a cid from a marshaled string
c
,
err
:=
cid
.
Decode
(
"
zdvgqEMYmNeH5fKciougvQcfzMcNjF3Z1tPouJ8C7pc3pe63k
"
)
c
,
err
:=
cid
.
Decode
(
"
bafzbeigai3eoy2ccc7ybwjfz5r3rdxqrinwi4rwytly24tdbh6yk7zslrm
"
)
if
err
!=
nil
{
...
}
fmt
.
Println
(
"Got CID: "
,
c
)
...
...
cid.go
View file @
b1cc3e40
...
...
@@ -368,7 +368,7 @@ func (c Cid) String() string {
case
0
:
return
c
.
Hash
()
.
B58String
()
case
1
:
mbstr
,
err
:=
mbase
.
Encode
(
mbase
.
Base
58BTC
,
c
.
Bytes
())
mbstr
,
err
:=
mbase
.
Encode
(
mbase
.
Base
32
,
c
.
Bytes
())
if
err
!=
nil
{
panic
(
"should not error with hardcoded mbase: "
+
err
.
Error
())
}
...
...
cid_test.go
View file @
b1cc3e40
...
...
@@ -438,13 +438,13 @@ func TestHexDecode(t *testing.T) {
t
.
Fatal
(
err
)
}
if
c
.
String
()
!=
"
zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG
"
{
if
c
.
String
()
!=
"
bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm
"
{
t
.
Fatal
(
"hash value failed to round trip decoding from hex"
)
}
}
func
ExampleDecode
()
{
encoded
:=
"
zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG
"
encoded
:=
"
bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm
"
c
,
err
:=
Decode
(
encoded
)
if
err
!=
nil
{
fmt
.
Printf
(
"Error: %s"
,
err
)
...
...
@@ -452,11 +452,11 @@ func ExampleDecode() {
}
fmt
.
Println
(
c
)
// Output:
zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG
// Output:
bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm
}
func
TestFromJson
(
t
*
testing
.
T
)
{
cval
:=
"
zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG
"
cval
:=
"
bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm
"
jsoncid
:=
[]
byte
(
`{"/":"`
+
cval
+
`"}`
)
var
c
Cid
err
:=
json
.
Unmarshal
(
jsoncid
,
&
c
)
...
...
@@ -470,7 +470,7 @@ func TestFromJson(t *testing.T) {
}
func
TestJsonRoundTrip
(
t
*
testing
.
T
)
{
exp
,
err
:=
Decode
(
"
zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG
"
)
exp
,
err
:=
Decode
(
"
bafkreie5qrjvaw64n4tjm6hbnm7fnqvcssfed4whsjqxzslbd3jwhsk3mm
"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment