package main import ( "encoding/json" "io/ioutil" ) type Config struct { Targets []checkTarget Port int } func ReadConfig(file string) (Config, error) { bytes, err := ioutil.ReadFile(file) if err != nil { return Config{}, err } var result Config json.Unmarshal(bytes, &result) return result, nil }