Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadAll ¶
ReadAll legge il file zippato passato come parametro e restituisce un io.Reader e un eventuale errore.
func ReadAllGZ ¶
ReadAllGZ legge il file compresso in gzip passato come parametro e restituisce l'intero contenuto del file e un eventuale errore.
Example ¶
package main import ( "bufio" "compress/gzip" "context" "fmt" "log" "os" "github.com/axamon/hermes/zipfile" ) const data = ` test test test ` func main() { testfile := "test.zip" flags := os.O_WRONLY | os.O_CREATE | os.O_TRUNC file, err := os.OpenFile(testfile, flags, 0644) if err != nil { log.Fatalf("Failed to open zip for writing: %s", err) } zippato := gzip.NewWriter(file) _, err = zippato.Write([]byte(data)) zippato.Close() ctx := context.TODO() content, err := zipfile.ReadAll(ctx, testfile) scan := bufio.NewScanner(content) for scan.Scan() { line := scan.Text() fmt.Println(line) } file.Close() err = os.Remove(testfile) if err != nil { log.Fatalf("Failed to open zip for writing: %s", err) } }
Output: test test test
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.