Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Isolated the go doc examples into a separate file #25

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions example_test.go
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
}
28 changes: 0 additions & 28 deletions osmshortlink_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package osmshortlink

import (
"fmt"
"math"
"testing"
)
Expand Down Expand Up @@ -200,30 +199,3 @@ func TestDecodeShortLinkString(t *testing.T) {
})
}
}

func ExampleCreate() {
shortLink, err := 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 := Encode(46.05141, 14.50604, 17)
if err != nil {
panic(err)
}
fmt.Println(shortLink)
// Output: 0Ik3VNr_A-
}

func ExampleDecode() {
latitude, longitude, zoom, err := Decode("0Ik3VNr_A-")
if err != nil {
panic(err)
}
fmt.Println(latitude, longitude, zoom)
// Output: 46.05140447616577 14.506051540374756 17
}