Skip to content

whosonfirst/go-whosonfirst-id

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-whosonfirst-id

Go package for generating valid Who's On First IDs.

Documentation

Go Reference

Example

Error handling omitted for the sake of brevity.

Simple

package main

import (
	"context"
	"fmt"
	"testing"
)

func main() {

	ctx := context.Background()
	pr, _ := NewProvider(ctx)

	id, _ := pr.NewID(ctx)
	fmt.Println(id)
}

Fancy

The default Provider does not pre-generate or cache IDs. To do so create a custom Provider that does, use the handy NewProviderWithURI method:

package main

import (
	_ "github.com/aaronland/go-uid-whosonfirst"
)

import (
	"context"
	"fmt"
	_ "github.com/aaronland/go-uid-proxy"	
)

func main() {

	ctx := context.Background()

	uri := "proxy:///?provider=whosonfirst://&minimum=5&pool=memory%3A%2F%2F"
	cl, _ := NewProviderWithURI(ctx, uri)

	id, _ := cl.NextInt(ctx)
	fmt.Println(id)
}

This expects a valid go-uid-proxy URI string.

See also

About

Go package for generating valid Who's On First IDs.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages