-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Isolated the go doc examples into a separate file (#25)
Trying to get "Share", "Format" and "Run" buttons below examples on https://pkg.go.dev/github.com/stefanb/osmshortlink-go#pkg-functions as per * https://go.dev/blog/examples * https://pkg.go.dev/golang.org/x/example/hello/reverse#String * https://cs.opensource.google/go/x/example/+/master:hello/reverse/example_test.go
- Loading branch information
Showing
2 changed files
with
34 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package osmshortlink_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/stefanb/osmshortlink-go" | ||
) | ||
|
||
func ExampleCreate() { | ||
shortLink, err := osmshortlink.Create(46.05141, 14.50604, 17) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(shortLink) | ||
// Output: https://osm.org/go/0Ik3VNr_A-?m | ||
} | ||
|
||
func ExampleEncode() { | ||
shortLink, err := osmshortlink.Encode(46.05141, 14.50604, 17) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(shortLink) | ||
// Output: 0Ik3VNr_A- | ||
} | ||
|
||
func ExampleDecode() { | ||
latitude, longitude, zoom, err := osmshortlink.Decode("0Ik3VNr_A-") | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Println(latitude, longitude, zoom) | ||
// Output: 46.05140447616577 14.506051540374756 17 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters