go-bip21 is an open source library to handle the URI based on the BIP-21 standard.
$ go get github.com/yassun/go-bip21
Parse the URI bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=20.3&label=Luke-Jr
.
u, err := bip21.Parse("bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=20.3&label=Luke-Jr")
if err != nil {...}
// &{UrnScheme:bitcoin Address:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W Amount:20.3 Label:Luke-Jr Message: Params:map[]}
fmt.Printf("%+v\n", u)
Build the URI bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=20.3&label=Luke-Jr
u := &bip21.URIResources{
UrnScheme: "bitcoin",
Address: "175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W",
Amount: 20.3,
Label: "Luke-Jr",
Message: "",
Params: make(map[string]string),
}
uri, err := u.BuildURI()
if err != nil {...}
// bitcoin:175tWpb8K1S7NmH4Zx6rewF9WQrcZv245W?amount=20.3&label=Luke-Jr
fmt.Printf("%+v\n", uri)