Skip to content

Commit

Permalink
check stdmod existence by directly looking at the directory
Browse files Browse the repository at this point in the history
  • Loading branch information
hidetatz committed Jul 30, 2023
1 parent 9cae5f2 commit 91dc11b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions stdmod.go
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
package main

import (
"errors"
"os"
"path/filepath"
)

var stdmods = []string{
"os",
}

func isstdmod(target string) bool {
for _, m := range stdmods {
if target == m {
return true
}
f := modtofile(filepath.Join(stdmoddir(), target))
if _, err := os.Stat(f); err == nil {
return true
} else if errors.Is(err, os.ErrNotExist) {
return false
} else {
// other error. todo: handle
}

return false
}

func stdmoddir() string {
home, _ := os.UserHomeDir()
home, _ := os.UserHomeDir() // todo: handle error
return filepath.Join(home, "shiba/std")
}

0 comments on commit 91dc11b

Please sign in to comment.