mirror of
https://github.com/crazybber/awesome-patterns.git
synced 2024-11-29 00:25:20 +03:00
cmd examplte
This commit is contained in:
parent
64df91e09c
commit
1d8a410b93
21
cmd/main.go
Normal file
21
cmd/main.go
Normal 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
12
ioreader/main.go
Normal 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 you’re designing a package or utility (even if it’s 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() {
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user