Hi,
I want to check, if the value return by my function has the type *os.File
This my code :
func createFile(filename string) (*os.File, error) {
f, err := os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
return f, err
}
//Test code
filename := "testfile"
f, _ := createFile(filename)
c := &f.(*os.File)
fmt.Println(c)
Error return :
invalid type assertion: f.(*os.File) (non-interface type *os.File on left)
Process exiting with code: 1
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/e88406f6-7646-4cd9-9e0f-dfe6eae2581f%40googlegroups.com.