typora/note/Go/命令行小程序.md

20 lines
257 B
Markdown
Raw Permalink Normal View History

2024-12-11 21:48:55 -05:00
### 命令行小程序合计
- gzip 压缩
- gzip 解压
#### gzip 压缩
- go build -o gzip
- gzip < main.go > main.go.gz
```go
package main
import (
"compress/gzip"
"io"
"os"
)
func main() {
w := gzip.NewWriter(os.Stdout)
io.Copy(w, os.Stdin)
}
```