refactor and add some stuff

This commit is contained in:
Greg Gauthier 2021-03-09 18:52:34 +00:00
parent 77faccc29f
commit 3ab1b112ce
4 changed files with 56 additions and 4 deletions

14
commander.go Normal file
View File

@ -0,0 +1,14 @@
package main
import (
"os/exec"
"strings"
)
func execute(cmdstr string) (string, error) {
cmdargs := strings.Split(cmdstr, " ") // string arrayified
cmd := cmdargs[0] // command
cmdargs = append(cmdargs[:0], cmdargs[1:]...) // argument array sans cmd
out, err := exec.Command(cmd, cmdargs...).CombinedOutput()
return string(out[:]), err
}

26
filer.go Normal file
View File

@ -0,0 +1,26 @@
package main
import (
"log"
"os"
"path/filepath"
)
// for generating the project blanks
func createFile(fpath string) bool {
fl, err := newFile(fpath)
if err != nil {
log.Fatal(err)
return false
}
fl.Close()
return true
}
// in case we need a file we can edit
func newFile(fpath string) (*os.File, error) {
if err := os.MkdirAll(filepath.Dir(fpath), 0770); err != nil {
return nil, err
}
return os.Create(fpath)
}

5
go.mod
View File

@ -1,6 +1,3 @@
module projector module bitbucket.org/gmgauthier_ecs/projector
go 1.16 go 1.16
require (
)

15
main.go
View File

@ -1,4 +1,19 @@
package main package main
import (
"fmt"
"os"
)
func main() { func main() {
wd, _ := os.Getwd()
dirlist, _ := os.ReadDir(wd)
fmt.Println(wd)
for _, item := range dirlist {
if os.DirEntry.IsDir(item) {
fmt.Println(wd + "/" + os.DirEntry.Name(item) + "/")
} else {
fmt.Println(wd + "/" + os.DirEntry.Name(item))
}
}
} }