Created
May 7, 2019 01:33
-
-
Save hairyhenderson/4555ad1571a1a33597dafb8d429b33e1 to your computer and use it in GitHub Desktop.
Using gomplate datasources programatically
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
package main | |
import ( | |
"fmt" | |
"github.com/hairyhenderson/gomplate/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"]) | |
// country is CA | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Holy shit.. this is easy