package main
import ( "fmt" "os")
func main() { filename := os.Args[1] fmt.Println("Filename:", filename) var f *os.File if f, err := os.Open(filename); err == nil { if f == nil { panic(fmt.Errorf("os.Open did not return an error but file did not open")) } defer func() { if err := f.Close(); err != nil { panic(err) } }() } else { panic(err) } b := make([]byte, 1024) if _, err := f.Read(b); err == nil { fmt.Println(string(b)) } else { panic(err) }}
--
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 golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.