Merge pull request #210 from itmecho/feature/hacktober-go

Adding a basic go json example
This commit is contained in:
Luke Oliff
2018-10-08 08:48:26 -07:00
committed by GitHub
2 changed files with 26 additions and 0 deletions

22
code/hacktober.go Normal file
View File

@@ -0,0 +1,22 @@
package main
import (
"fmt"
"time"
"encoding/json"
)
type Hacktober struct {
Message string `json:"msg"`
Date time.Time `json:"date"`
}
func main () {
data := Hacktober{
Message: "Hello Hacktoberfest 2018!",
Date: time.Now(),
}
jsonBytes, _ := json.MarshalIndent(data, "", " ")
fmt.Println(string(jsonBytes))
}