summaryrefslogtreecommitdiff
path: root/examples/foo.go
diff options
context:
space:
mode:
Diffstat (limited to 'examples/foo.go')
-rw-r--r--examples/foo.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/examples/foo.go b/examples/foo.go
new file mode 100644
index 00000000..48e165d4
--- /dev/null
+++ b/examples/foo.go
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+
+ "github.com/hairyhenderson/gomplate/v3/data"
+)
+
+func main() {
+ d, err := data.NewData([]string{"ip=https://ipinfo.io"}, nil)
+ if err != nil {
+ panic(err)
+ }
+
+ response, err := d.Datasource("ip")
+ if err != nil {
+ panic(err)
+ }
+
+ m := response.(map[string]interface{})
+ fmt.Printf("country is %s\n", m["country"])
+}