did

package module
v0.0.0-...-bf4a5b5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2025 License: MIT Imports: 3 Imported by: 1

README

go-did

Package did implements Decentralized Identifiers (DIDs), for the Go programming language.

As defined here: https://www.w3.org/TR/did-core/

Documention

Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-did

GoDoc

Import

To import package did use import code like the following:

import "github.com/reiver/go-did"

Installation

To install package did do the following:

GOPROXY=direct go get github.com/reiver/go-did

Author

Package did was written by Charles Iliya Krempeaux

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateScheme

func ValidateScheme(uri string) error

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

func ConstructDID(methodName string, identifier string) (DID, error)

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

func MustConstructDID(methodName string, identifier string) DID

MustConstructDID is similar to ConstructDID except it panic()s if there is an error.

func (DID) DecompileDID

func (receiver DID) DecompileDID() (methodName string, identifier string, err error)

func (DID) Identifier

func (receiver DID) Identifier() string

func (DID) MarshalText

func (receiver DID) MarshalText() ([]byte, error)

func (DID) MethodName

func (receiver DID) MethodName() string

func (DID) String

func (receiver DID) String() string

func (*DID) UnmarshalText

func (receiver *DID) UnmarshalText(text []byte) error

func (DID) Validate

func (receiver DID) Validate() error

Validator returns an error did the did.DID is not valid.

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL