2024-08-02 21:48:26 +00:00
|
|
|
package global
|
|
|
|
|
|
|
|
import (
|
2024-08-31 01:56:06 +00:00
|
|
|
"fmt"
|
2024-08-02 21:48:26 +00:00
|
|
|
"os"
|
2024-08-31 01:56:06 +00:00
|
|
|
"strings"
|
2024-08-02 21:48:26 +00:00
|
|
|
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
)
|
|
|
|
|
2024-08-31 01:56:06 +00:00
|
|
|
var Args = func() map[string]string {
|
|
|
|
args := map[string]string{}
|
|
|
|
|
|
|
|
index := 0
|
|
|
|
for index < len(os.Args[1:]) {
|
|
|
|
arg := os.Args[index + 1]
|
|
|
|
if !strings.HasPrefix(arg, "-") {
|
|
|
|
fmt.Printf("FATAL: Parameters must follow an argument (%s).\n", arg)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
|
|
|
|
if index + 3 > len(os.Args) || strings.HasPrefix(os.Args[index + 2], "-") {
|
|
|
|
args[arg[1:]] = "true"
|
|
|
|
index += 1
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
val := os.Args[index + 2]
|
|
|
|
args[arg[1:]] = val
|
|
|
|
// fmt.Printf("%s: %s\n", arg[1:], val)
|
|
|
|
index += 2
|
|
|
|
}
|
|
|
|
|
|
|
|
return args
|
|
|
|
}()
|
|
|
|
|
2024-08-02 21:48:26 +00:00
|
|
|
var HTTP_DOMAIN = func() string {
|
2024-09-03 07:07:45 +00:00
|
|
|
domain := os.Getenv("HTTP_DOMAIN")
|
|
|
|
if domain == "" {
|
|
|
|
return "https://arimelody.me"
|
2024-08-02 21:48:26 +00:00
|
|
|
}
|
2024-09-03 07:07:45 +00:00
|
|
|
return domain
|
2024-08-31 01:56:06 +00:00
|
|
|
}()
|
2024-08-02 21:48:26 +00:00
|
|
|
|
|
|
|
var DB *sqlx.DB
|