https://github.com/reiver/go-hashuri
Parses Hash URIs, for the Go programming language.
https://github.com/reiver/go-hashuri
content-addressed content-addressing hash-uri uri-parser
Last synced: 2 months ago
JSON representation
Parses Hash URIs, for the Go programming language.
- Host: GitHub
- URL: https://github.com/reiver/go-hashuri
- Owner: reiver
- License: mit
- Created: 2018-07-28T03:46:20.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-28T05:14:40.000Z (almost 7 years ago)
- Last Synced: 2025-04-09T09:46:30.643Z (2 months ago)
- Topics: content-addressed, content-addressing, hash-uri, uri-parser
- Language: Go
- Homepage: https://godoc.org/github.com/reiver/go-hashuri
- Size: 12.7 KB
- Stars: 6
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-hashuri
Package **hashuri** parses Hash URIs, for the Go programming language.
And works seemlessly with the Go built-in packages: `"database/sql"`, `"fmt"`, `"encoding/json"`.
## Documention
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-hashuri
[](https://godoc.org/github.com/reiver/go-hashuri)
## Hash URI Examples
Hash URIs often look like this:
```
hash://sha256/0ba904eae8773b70c75333db4de2f3ac45a8ad4ddba1b242f0b3cfc199391dd8
\__/ \____/ \______________________________________________________________/
| | |
scheme algorithm hash
```But, more generally, can look like this:
```
hash://sha256/0ba904eae8773b70c75333db4de2f3ac45a8ad4ddba1b242f0b3cfc199391dd8?apple=one&banana=۲&cherry=3#over-there
\__/ \____/ \______________________________________________________________/ \_________________________/ \________/
| | | | |
scheme algorithm hash query fragment
```## Go Example
Basic usage of this package looks like this:
```go
import "github.com/reiver/go-hashuri"var hashURI string = "hash://sha256/0ba904eae8773b70c75333db4de2f3ac45a8ad4ddba1b242f0b3cfc199391dd8"
var parsedHashURI hashuri.Type
if err := hashuri.Parse(&parsedHashURI, hashURI); nil != err {
return err
}fmt.Printf("Hash URI algorithm: %q \n", parsedHashURI.Algorithm) // Hash URI algorithm: "sha256"
fmt.Printf("Hash URI hash: %q \n", parsedHashURI.Hash) // Hash URI hash: "0ba904eae8773b70c75333db4de2f3ac45a8ad4ddba1b242f0b3cfc199391dd8"
fmt.Printf("Hash URI raw query: %q \n", parsedHashURI.RawQuery) // Hash URI raw query: ""
fmt.Printf("Hash URI fragment: %q \n", parsedHashURI.Fragment) // Hash URI fragment: ""
```## See Also
The **Hash URI** specification can be found at: https://github.com/hash-uri/hash-uri