12345678910111213141516171819202122232425262728 |
- package utils
- import (
- "log"
- "os"
- "runtime"
- "strconv"
- "strings"
- )
- func Cwd(i int) string {
- _, fp, _, _ := runtime.Caller(i)
- slice := strings.Split(fp, "/")
- slice = slice[:len(slice)-1]
- path := strings.Join(slice, "/")
- return path
- }
- func CheckArgs() {
- if len(os.Args) < 2 {
- log.Fatalf("ERROR: port number required: eg ./bin 3000")
- }
- _, err := strconv.Atoi(os.Args[1])
- if err != nil {
- log.Fatalf("ERROR: port must be a number")
- }
- }
|