This is a created article in which the information may have evolved or changed.
Today we have a look at the operation of the zip archive for the go language.
Every day to see a little go bag, hands-on to write a few examples feel still a little harvest, more hands to progress.
Attach the code first. Testzip.go
Package Mainimport ("Archive/zip" "Bufio" "FMT" "IO" "OS") Func main () {RC, err: = Zip. Openreader ("Test/hello.zip") if err! = nil {defer RC. Close ()}for _, _file: = Range RC. File {fmt. Println (_file. Name) F, _: = _file. Open () desfile, err1: = OS. OpenFile (_file. Name, OS. O_create|os. O_wronly, OS. modeperm) If err1 = = Nil {fmt. Println ("OK") io. Copyn (Desfile, F, Int64 (_file. UNCOMPRESSEDSIZE64)) Desfile. Close ()} else {defer desfile. Close ()}}}
Then go run Testzip.go is OK.
General Go official documentation is quite complete, in addition to some of the difficulty of the basic document can be solved.
The original saw a video, there is a good classic, 10 minutes of programming every day, life is good and easy!
I wish you all a pleasant