Compare commits

...

7 Commits

Author SHA1 Message Date
Jorropo
085afa84d0 chore: release v0.3.0 2022-08-25 05:34:36 +02:00
Jorropo
0052a62190 fix: return nil Bytes() if the Cid in undef 2022-08-25 05:34:36 +02:00
GitHub
802b45594e chore: Update .github/workflows/stale.yml [skip ci] 2022-07-21 09:54:55 +00:00
Steven Allen
8f7d7ac18e Merge pull request #139 from mg98/feat/must-parse
Add MustParse
2022-06-27 08:55:37 -07:00
GitHub
b106e0883a Update .github/workflows/stale.yml 2022-06-27 10:45:49 +00:00
Marcel Gregoriadis
386c6cc18a Add MustParse 2022-06-24 17:35:23 +02:00
ipfs-mgmt-read-write[bot]
f4b3e66993 Add .github/workflows/stale.yml 2022-06-13 12:53:24 +00:00
3 changed files with 42 additions and 1 deletions

26
.github/workflows/stale.yml vendored Normal file
View File

@@ -0,0 +1,26 @@
name: Close and mark stale issue
on:
schedule:
- cron: '0 0 * * *'
jobs:
stale:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: 'Oops, seems like we needed more information for this issue, please comment with more details or this issue will be closed in 7 days.'
close-issue-message: 'This issue was closed because it is missing author input.'
stale-issue-label: 'kind/stale'
any-of-labels: 'need/author-input'
exempt-issue-labels: 'need/triage,need/community-input,need/maintainer-input,need/maintainers-input,need/analysis,status/blocked,status/in-progress,status/ready,status/deferred,status/inactive'
days-before-issue-stale: 6
days-before-issue-close: 7
enable-statistics: true

15
cid.go
View File

@@ -181,6 +181,15 @@ func Parse(v interface{}) (Cid, error) {
} }
} }
// MustParse calls Parse but will panic on error.
func MustParse(v interface{}) Cid {
c, err := Parse(v)
if err != nil {
panic(err)
}
return c
}
// Decode parses a Cid-encoded string and returns a Cid object. // Decode parses a Cid-encoded string and returns a Cid object.
// For CidV1, a Cid-encoded string is primarily a multibase string: // For CidV1, a Cid-encoded string is primarily a multibase string:
// //
@@ -369,7 +378,13 @@ func (c Cid) Hash() mh.Multihash {
// Bytes returns the byte representation of a Cid. // Bytes returns the byte representation of a Cid.
// The output of bytes can be parsed back into a Cid // The output of bytes can be parsed back into a Cid
// with Cast(). // with Cast().
//
// If c.Defined() == false, it return a nil slice and may not
// be parsable with Cast().
func (c Cid) Bytes() []byte { func (c Cid) Bytes() []byte {
if !c.Defined() {
return nil
}
return []byte(c.str) return []byte(c.str)
} }

View File

@@ -1,3 +1,3 @@
{ {
"version": "v0.2.0" "version": "v0.3.0"
} }