fix: typo (#157)

* fix: typo

* fix: typo

* fix: typo

* refactor: if -> switch

* style: make gopls happy
This commit is contained in:
BoYanZh 2025-06-26 14:33:06 -04:00 committed by GitHub
parent 6211423165
commit 2b42c8bed5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 10 additions and 9 deletions

View File

@ -43,7 +43,7 @@ var (
srcPrefix []string srcPrefix []string
) )
func newFilsStore(dir string) (filestore.FileStore, error) { func newFileStore(dir string) (filestore.FileStore, error) {
if dir == "" { if dir == "" {
if runtime.GOOS == "linux" { if runtime.GOOS == "linux" {
dir = "/dev/shm" dir = "/dev/shm"
@ -83,7 +83,7 @@ func Init(i *C.char) C.int {
srcPrefix = strings.Split(ip.SrcPrefix, ",") srcPrefix = strings.Split(ip.SrcPrefix, ",")
var err error var err error
fs, err = newFilsStore(ip.Dir) fs, err = newFileStore(ip.Dir)
if err != nil { if err != nil {
log.Fatalln("file store create failed", err) log.Fatalln("file store create failed", err)
} }

View File

@ -30,14 +30,15 @@ func newListener(addr string) (net.Listener, error) {
} }
var ips []net.IP var ips []net.IP
if host == "" { switch host {
case "":
return net.Listen("tcp", addr) return net.Listen("tcp", addr)
} else if host == "localhost" { case "localhost":
ips, err = getLocalhostIP() ips, err = getLocalhostIP()
if err != nil { if err != nil {
return nil, err return nil, err
} }
} else { default:
ips, err = net.LookupIP(host) ips, err = net.LookupIP(host)
if err != nil { if err != nil {
return nil, err return nil, err

View File

@ -64,7 +64,7 @@ func main() {
warnIfNotLinux() warnIfNotLinux()
// Init environment pool // Init environment pool
fs, fsCleanUp := newFilsStore(conf) fs, fsCleanUp := newFileStore(conf)
b, builderParam := newEnvBuilder(conf) b, builderParam := newEnvBuilder(conf)
envPool := newEnvPool(b, conf.EnableMetrics) envPool := newEnvPool(b, conf.EnableMetrics)
prefork(envPool, conf.PreFork) prefork(envPool, conf.PreFork)
@ -455,7 +455,7 @@ func grpcTokenAuth(token string) func(context.Context) (context.Context, error)
} }
} }
func newFilsStore(conf *config.Config) (filestore.FileStore, func() error) { func newFileStore(conf *config.Config) (filestore.FileStore, func() error) {
const timeoutCheckInterval = 15 * time.Second const timeoutCheckInterval = 15 * time.Second
var cleanUp func() error var cleanUp func() error
@ -555,7 +555,7 @@ func newForceGCWorker(conf *config.Config) {
}() }()
} }
func generateHandleVersion(conf *config.Config, builderParam map[string]any) func(*gin.Context) { func generateHandleVersion(_ *config.Config, _ map[string]any) func(*gin.Context) {
return func(c *gin.Context) { return func(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{ c.JSON(http.StatusOK, gin.H{
"buildVersion": version.Version, "buildVersion": version.Version,

2
env/env_linux.go vendored
View File

@ -292,7 +292,7 @@ func kernelVersion() (major int, minor int) {
value = (value * 10) + int(c-'0') value = (value * 10) + int(c-'0')
} else { } else {
// Note that we're assuming N.N.N here. If we see anything else we are likely to // Note that we're assuming N.N.N here. If we see anything else we are likely to
// mis-parse it. // misparse it.
values[vi] = value values[vi] = value
vi++ vi++
if vi >= len(values) { if vi >= len(values) {