mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-05-14 00:51:12 +03:00
Add runtime warnings
This commit is contained in:
68
constant/goos/gengoos.go
Normal file
68
constant/goos/gengoos.go
Normal file
@@ -0,0 +1,68 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var gooses []string
|
||||
|
||||
func main() {
|
||||
data, err := os.ReadFile("../../go/build/syslist.go")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
const goosPrefix = `const goosList = `
|
||||
for _, line := range strings.Split(string(data), "\n") {
|
||||
if strings.HasPrefix(line, goosPrefix) {
|
||||
text, err := strconv.Unquote(strings.TrimPrefix(line, goosPrefix))
|
||||
if err != nil {
|
||||
log.Fatalf("parsing goosList: %v", err)
|
||||
}
|
||||
gooses = strings.Fields(text)
|
||||
}
|
||||
}
|
||||
|
||||
for _, target := range gooses {
|
||||
if target == "nacl" {
|
||||
continue
|
||||
}
|
||||
var tags []string
|
||||
if target == "linux" {
|
||||
tags = append(tags, "!android") // must explicitly exclude android for linux
|
||||
}
|
||||
if target == "solaris" {
|
||||
tags = append(tags, "!illumos") // must explicitly exclude illumos for solaris
|
||||
}
|
||||
if target == "darwin" {
|
||||
tags = append(tags, "!ios") // must explicitly exclude ios for darwin
|
||||
}
|
||||
tags = append(tags, target) // must explicitly include target for bootstrapping purposes
|
||||
var buf bytes.Buffer
|
||||
fmt.Fprintf(&buf, "// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.\n\n")
|
||||
fmt.Fprintf(&buf, "//go:build %s\n", strings.Join(tags, " && "))
|
||||
fmt.Fprintf(&buf, "package goos\n\n")
|
||||
fmt.Fprintf(&buf, "const GOOS = `%s`\n\n", target)
|
||||
for _, goos := range gooses {
|
||||
value := 0
|
||||
if goos == target {
|
||||
value = 1
|
||||
}
|
||||
fmt.Fprintf(&buf, "const Is%s = %d\n", strings.Title(goos), value)
|
||||
}
|
||||
err := os.WriteFile("zgoos_"+target+".go", buf.Bytes(), 0o666)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
12
constant/goos/goos.go
Normal file
12
constant/goos/goos.go
Normal file
@@ -0,0 +1,12 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// package goos contains GOOS-specific constants.
|
||||
package goos
|
||||
|
||||
// The next line makes 'go generate' write the zgoos*.go files with
|
||||
// per-OS information, including constants named Is$GOOS for every
|
||||
// known GOOS. The constant is 1 on the current system, 0 otherwise;
|
||||
// multiplying by them is useful for defining GOOS-specific constants.
|
||||
//go:generate go run gengoos.go
|
||||
25
constant/goos/zgoos_aix.go
Normal file
25
constant/goos/zgoos_aix.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build aix
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `aix`
|
||||
|
||||
const IsAix = 1
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_android.go
Normal file
25
constant/goos/zgoos_android.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build android
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `android`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 1
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_darwin.go
Normal file
25
constant/goos/zgoos_darwin.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build !ios && darwin
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `darwin`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 1
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_dragonfly.go
Normal file
25
constant/goos/zgoos_dragonfly.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build dragonfly
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `dragonfly`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 1
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_freebsd.go
Normal file
25
constant/goos/zgoos_freebsd.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build freebsd
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `freebsd`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 1
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_hurd.go
Normal file
25
constant/goos/zgoos_hurd.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build hurd
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `hurd`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 1
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_illumos.go
Normal file
25
constant/goos/zgoos_illumos.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build illumos
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `illumos`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 1
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_ios.go
Normal file
25
constant/goos/zgoos_ios.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build ios
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `ios`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 1
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_js.go
Normal file
25
constant/goos/zgoos_js.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build js
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `js`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 1
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_linux.go
Normal file
25
constant/goos/zgoos_linux.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build !android && linux
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `linux`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 1
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_netbsd.go
Normal file
25
constant/goos/zgoos_netbsd.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build netbsd
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `netbsd`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 1
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_openbsd.go
Normal file
25
constant/goos/zgoos_openbsd.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build openbsd
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `openbsd`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 1
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_plan9.go
Normal file
25
constant/goos/zgoos_plan9.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build plan9
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `plan9`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 1
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_solaris.go
Normal file
25
constant/goos/zgoos_solaris.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build !illumos && solaris
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `solaris`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 1
|
||||
const IsWindows = 0
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_windows.go
Normal file
25
constant/goos/zgoos_windows.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build windows
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `windows`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 1
|
||||
const IsZos = 0
|
||||
25
constant/goos/zgoos_zos.go
Normal file
25
constant/goos/zgoos_zos.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Code generated by gengoos.go using 'go generate'. DO NOT EDIT.
|
||||
|
||||
//go:build zos
|
||||
|
||||
package goos
|
||||
|
||||
const GOOS = `zos`
|
||||
|
||||
const IsAix = 0
|
||||
const IsAndroid = 0
|
||||
const IsDarwin = 0
|
||||
const IsDragonfly = 0
|
||||
const IsFreebsd = 0
|
||||
const IsHurd = 0
|
||||
const IsIllumos = 0
|
||||
const IsIos = 0
|
||||
const IsJs = 0
|
||||
const IsLinux = 0
|
||||
const IsNacl = 0
|
||||
const IsNetbsd = 0
|
||||
const IsOpenbsd = 0
|
||||
const IsPlan9 = 0
|
||||
const IsSolaris = 0
|
||||
const IsWindows = 0
|
||||
const IsZos = 1
|
||||
37
constant/os.go
Normal file
37
constant/os.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package constant
|
||||
|
||||
import (
|
||||
"github.com/sagernet/sing-box/constant/goos"
|
||||
)
|
||||
|
||||
const IsAndroid = goos.IsAndroid == 1
|
||||
|
||||
const IsDarwin = goos.IsDarwin == 1
|
||||
|
||||
const IsDragonfly = goos.IsDragonfly == 1
|
||||
|
||||
const IsFreebsd = goos.IsFreebsd == 1
|
||||
|
||||
const IsHurd = goos.IsHurd == 1
|
||||
|
||||
const IsIllumos = goos.IsIllumos == 1
|
||||
|
||||
const IsIos = goos.IsIos == 1
|
||||
|
||||
const IsJs = goos.IsJs == 1
|
||||
|
||||
const IsLinux = goos.IsLinux == 1
|
||||
|
||||
const IsNacl = goos.IsNacl == 1
|
||||
|
||||
const IsNetbsd = goos.IsNetbsd == 1
|
||||
|
||||
const IsOpenbsd = goos.IsOpenbsd == 1
|
||||
|
||||
const IsPlan9 = goos.IsPlan9 == 1
|
||||
|
||||
const IsSolaris = goos.IsSolaris == 1
|
||||
|
||||
const IsWindows = goos.IsWindows == 1
|
||||
|
||||
const IsZos = goos.IsZos == 1
|
||||
Reference in New Issue
Block a user