Created
August 22, 2018 14:40
-
-
Save kesor/0ad1b334a390fda10d8cf33a84a9b115 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 ( | |
"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