Skip to content

Instantly share code, notes, and snippets.

@kesor
Created August 22, 2018 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kesor/0ad1b334a390fda10d8cf33a84a9b115 to your computer and use it in GitHub Desktop.
Save kesor/0ad1b334a390fda10d8cf33a84a9b115 to your computer and use it in GitHub Desktop.
package main
import (
"encoding/json"
"fmt"
)
type ServiceDescriptionPayload struct {
Address string `json:"address"`
}
type ServiceDescription struct {
Action string `json:"action"`
Payload ServiceDescriptionPayload `json:"payload"`
}
func main() {
publicIP := "8.8.8.8"
serviceDescription, err := json.Marshal(ServiceDescription{
Action: "write",
Payload: ServiceDescriptionPayload{
Address: publicIP,
},
})
if err != nil {
// ...
}
fmt.Println(serviceDescription)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment