/* Digby: A multi-file copmressor */ package main import ( "bufio" "compress/gzip" "compress/zlib" "fmt" "io/ioutil" "os" ) func main() { // Asks user what file to compress and stores it as `file` fmt.Printf("What file would you like to copmress: ") var file string fmt.Scanln(&file) // Asks user what dir to save the file. fmt.Printf("\n\nWhat directory would you like to save your file: ") var path string fmt.Scanln(&path) fmt.Printf("\n\nWhat compression system: ") var comp string fmt.Scanln(&comp) // Compression shit f, _ := os.Open(*&path + *&file) read := bufio.NewReader(f) data, _ := ioutil.ReadAll(read) if *&comp == "gzip" { f, _ = os.Create(*&path + *&file + ".gz") w := gzip.NewWriter(f) w.Write(data) w.Close() } else if *&comp == "zlib" { f, _ = os.Create(*&path + *&file + ".zlib") w := zlib.NewWriter(f) w.Write(data) w.Close() } }