Skip to content

Commit

Permalink
FIX interface inside loop and error check
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Zaneri committed Jan 14, 2020
1 parent 466d7b3 commit 45a9468
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions cmd/removefield/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,19 @@ func readFile (path string) []byte {
if err != nil {
log.Fatal(err)
}

defer file.Close()

configuration, err := ioutil.ReadAll(file)

if err != nil {
log.Fatal(err)
}

return configuration
}

func removeField(path, field string) {
var t interface{}

var buffer []byte

Expand All @@ -32,6 +37,7 @@ func removeField(path, field string) {
resources := bytes.Split(configuration, []byte("---"))

for _, config := range resources {
var t interface{}

err := yaml.Unmarshal(config, &t)

Expand Down Expand Up @@ -61,7 +67,7 @@ func removeField(path, field string) {
func main() {

if len(os.Args) != 3 {
log.Fatalf("Usage: ./remove_field filename")
log.Fatalf("Usage: ./remove_field filename field")
}

filePath := os.Args[1]
Expand Down

0 comments on commit 45a9468

Please sign in to comment.