seperared json func.
This commit is contained in:
parent
388d0a259d
commit
e94125f510
18
json.go
Normal file
18
json.go
Normal file
@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os"
|
||||
)
|
||||
|
||||
func loadJson(file string) (WeatherAPI, error) {
|
||||
var config WeatherAPI
|
||||
configFile, err := os.Open(file)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
jsonParser := json.NewDecoder(configFile)
|
||||
jsonParser.Decode(&config)
|
||||
return config, err
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user