cmd examplte

This commit is contained in:
Jian Han 2018-01-21 20:53:34 +10:00
parent 64df91e09c
commit 1d8a410b93
2 changed files with 33 additions and 0 deletions

21
cmd/main.go Normal file
View File

@ -0,0 +1,21 @@
package main
import (
"fmt"
"os"
"os/exec"
"github.com/davecgh/go-spew/spew"
)
func main() {
cmd := "ls"
args := []string{"-ll"}
out, err := exec.Command(cmd, args...).Output()
spew.Dump(string(out), err)
if err := exec.Command(cmd, args...).Run(); err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println("Successfully halved image in size")
}

12
ioreader/main.go Normal file
View File

@ -0,0 +1,12 @@
package main
// https://medium.com/@matryer/golang-advent-calendar-day-seventeen-io-reader-in-depth-6f744bb4320b
// Take io.Reader when you can
// If youre designing a package or utility (even if its an internal thing that nobody will ever see)
// rather than taking in strings or []byte slices, consider taking in an io.Reader if you can for data sources.
// Because suddenly, your code will work with every type that implements io.Reader.
func main() {
}