-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix/drop-gogo
- Loading branch information
Showing
12 changed files
with
86 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package internal | ||
|
||
import ( | ||
"time" | ||
|
||
mh "github.com/multiformats/go-multihash" | ||
) | ||
|
||
// Hash is the global IPFS hash function. uses multihash SHA2_256, 256 bits | ||
func Hash(data []byte) mh.Multihash { | ||
h, err := mh.Sum(data, mh.SHA2_256, -1) | ||
if err != nil { | ||
// this error can be safely ignored (panic) because multihash only fails | ||
// from the selection of hash function. If the fn + length are valid, it | ||
// won't error. | ||
panic("multihash failed to hash using SHA2_256.") | ||
} | ||
return h | ||
} | ||
|
||
// ParseRFC3339 parses an RFC3339Nano-formatted time stamp and | ||
// returns the UTC time. | ||
func ParseRFC3339(s string) (time.Time, error) { | ||
t, err := time.Parse(time.RFC3339Nano, s) | ||
if err != nil { | ||
return time.Time{}, err | ||
} | ||
return t.UTC(), nil | ||
} | ||
|
||
// FormatRFC3339 returns the string representation of the | ||
// UTC value of the given time in RFC3339Nano format. | ||
func FormatRFC3339(t time.Time) string { | ||
return t.UTC().Format(time.RFC3339Nano) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.