Documentation
¶
Index ¶
- func ValidateScheme(uri string) error
- type DID
- func (receiver DID) DecompileDID() (methodName string, identifier string, err error)
- func (receiver DID) Identifier() string
- func (receiver DID) MarshalText() ([]byte, error)
- func (receiver DID) MethodName() string
- func (receiver DID) String() string
- func (receiver *DID) UnmarshalText(text []byte) error
- func (receiver DID) Validate() error
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateScheme ¶
ValidateScheme only validates the scheme of a potential DID.
So, it checks to see if the URI starts with "did:". And, that is it.
You would use ValidateScheme if you wanted to be very liberal in what you accept as a valid DID, including not caring if the DID has a 'method-name' or a 'method-specific-id'. I.e., this is the minimum amount of validation you can do to validate a DID.
Example ¶
package main
import (
"fmt"
"github.com/reiver/go-did"
)
func main() {
var uri string = "http://example.com/once/twice/thrice/fource.html"
err := did.ValidateScheme(uri)
fmt.Printf("error: %s\n", err)
}
Output: error: did: URI "http://example.com/once/twice/thrice/fource.html" is not a DID because it does not begin with "did:"
Types ¶
type DID ¶
type DID string
DID represents a decentralized-identifier (DID).
DIDs are defined here: https://www.w3.org/TR/did-core/#did-syntax
func ConstructDID ¶
ConstructDID creates a did.DID based on a method-name and identifier.
ConstructDID also validates both method-name and identifier, and returns an error if either (or both) of them fail validation.
func MustConstructDID ¶
MustConstructDID is similar to ConstructDID except it panic()s if there is an error.