file, err := os.Open("test.go") defer file.Close() if err != nil { fmt.Println("open file failed:",err) return }