packagecommonimport("encoding/json""fmt""io/ioutil")// LoadJSON reads the given file and unmarshals its content.funcLoadJSON(filestring,valinterface{})error{content,err:=ioutil.ReadFile(file)iferr!=nil{returnerr}iferr:=json.Unmarshal(content,val);err!=nil{ifsyntaxerr,ok:=err.(*json.SyntaxError);ok{line:=findLine(content,syntaxerr.Offset)returnfmt.Errorf("JSON syntax error at %v:%v: %v",file,line,err)}returnfmt.Errorf("JSON unmarshal error in %v: %v",file,err)}returnnil}// findLine returns the line number for the given offset into data.funcfindLine(data[]byte,offsetint64)(lineint){line=1fori,r:=rangestring(data){ifint64(i)>=offset{return}ifr=='\n'{line++}}return}