This is a creation in
Article, where the information may have evolved or changed.
Recently, looking at the go language, just experience the legendary power.
This code example is the go language operation file: File.go
Package Mainimport ("bytes" "FMT" "OS") Func main () {file, err: = OS. Open ("File.go") if err! = Nil {defer file. Close () fmt. Println (Err. Error ())}else{fileinfo, _: = file. Stat () fmt. Println (FileInfo. Size (), FileInfo. Name ()) FileSize: = FileInfo. Size () Buffer: = Make ([]byte, filesize) file. Read (buffer) fmt. PRINTLN (buffer) Bufs: = bytes. Newbuffer (buffer) fmt. Println (Bufs. String ())
}}
The result output is that he himself hehe
Package Mainimport ("bytes" "FMT" "OS") Func main () {file, err: = OS. Open ("File.go") if err! = Nil {defer file. Close () fmt. Println (Err. Error ())}else{fileinfo, _: = file. Stat () fmt. Println (FileInfo. Size (), FileInfo. Name ()) FileSize: = FileInfo. Size () Buffer: = Make ([]byte, filesize) file. Read (buffer) fmt. PRINTLN (buffer) Bufs: = bytes. Newbuffer (buffer) fmt. Println (Bufs. String ())
}}