-
Notifications
You must be signed in to change notification settings - Fork 0
/
letsgo.go
50 lines (42 loc) · 865 Bytes
/
letsgo.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"bufio"
"fmt"
"io"
"os"
)
func main() {
// cmd := exec.Command("./letsgo.sh")
// cmd.Stdin = os.Stdin
// cmd.Stdout = os.Stdout
// cmd.Stderr = os.Stderr
// if err := cmd.Run(); err != nil {
// log.Fatal(err)
// }
r := Runner{
stdin: os.Stdin,
stdout: os.Stdout,
buf: []byte{},
}
var gopath, username string
gopath = "testing/hi/sup/go"
r.makeUserRepo(gopath + "/src/github.com/" + username)
}
type Runner struct {
stdin io.Reader
stdout io.Writer
buf []byte
}
func (r Runner) makeUserRepo(dir string) {
fmt.Fprintln(r.stdout, "What's your github handle?")
r.read()
if err := os.MkdirAll(dir, os.ModeDir|0755); err != nil {
panic(err)
}
fmt.Fprintln(r.stdout, dir+"is all set\n")
}
func (r Runner) read() []byte {
scanner := bufio.NewScanner(r.stdin)
scanner.Scan()
return scanner.Bytes()
}