mirror of
https://github.com/c0de-archive/hacktoberfest-2018.git
synced 2025-07-30 13:30:16 +00:00
Adding basic golang json example
This commit is contained in:
22
code/hacktober.go
Normal file
22
code/hacktober.go
Normal 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))
|
||||||
|
}
|
Reference in New Issue
Block a user