Files
codeql/go/ql/src/InconsistentCode/MissingErrorCheckGood.go
2022-05-20 10:07:19 -07:00

19 lines
256 B
Go

package main
import (
"fmt"
"os"
)
func user(input string) {
ptr, err := os.Open(input)
if err != nil {
fmt.Printf("Bad input: %s\n", input)
return
}
// GOOD: `err` has been checked before `ptr` is used
fmt.Printf("Result was %v\n", *ptr)
}