mirror of
https://github.com/containers/podman.git
synced 2025-09-20 11:13:54 +08:00
linter: enable errchkjson
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
This commit is contained in:
@ -62,7 +62,6 @@ linters:
|
|||||||
- ireturn
|
- ireturn
|
||||||
- tagliatelle
|
- tagliatelle
|
||||||
- varnamelen
|
- varnamelen
|
||||||
- errchkjson
|
|
||||||
- maintidx
|
- maintidx
|
||||||
- nilerr
|
- nilerr
|
||||||
- nilnil
|
- nilnil
|
||||||
|
@ -102,9 +102,10 @@ var _ = Describe("Common functions test", func() {
|
|||||||
Item2: []string{"test"},
|
Item2: []string{"test"},
|
||||||
}
|
}
|
||||||
|
|
||||||
testByte, _ := json.Marshal(testData)
|
testByte, err := json.Marshal(testData)
|
||||||
err := WriteJSONFile(testByte, "/tmp/testJSON")
|
Expect(err).To(BeNil(), "Failed to marshal data.")
|
||||||
|
|
||||||
|
err = WriteJSONFile(testByte, "/tmp/testJSON")
|
||||||
Expect(err).To(BeNil(), "Failed to write JSON to file.")
|
Expect(err).To(BeNil(), "Failed to write JSON to file.")
|
||||||
|
|
||||||
read, err := os.Open("/tmp/testJSON")
|
read, err := os.Open("/tmp/testJSON")
|
||||||
|
@ -479,7 +479,10 @@ func IsCommandAvailable(command string) bool {
|
|||||||
func WriteJSONFile(data []byte, filePath string) error {
|
func WriteJSONFile(data []byte, filePath string) error {
|
||||||
var jsonData map[string]interface{}
|
var jsonData map[string]interface{}
|
||||||
json.Unmarshal(data, &jsonData)
|
json.Unmarshal(data, &jsonData)
|
||||||
formatJSON, _ := json.MarshalIndent(jsonData, "", " ")
|
formatJSON, err := json.MarshalIndent(jsonData, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
return ioutil.WriteFile(filePath, formatJSON, 0644)
|
return ioutil.WriteFile(filePath, formatJSON, 0644)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user