parent
77faccc29f
commit
3ab1b112ce
4 changed files with 56 additions and 4 deletions
@ -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 |
||||
} |
@ -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) |
||||
} |
@ -1,4 +1,19 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"os" |
||||
) |
||||
|
||||
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)) |
||||
} |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue