ok cool lets make CheckEnv actually do something and oh lets make it modular
Signed-off-by: Odyssey346 <odyssey346@disroot.org>
This commit is contained in:
parent
7fb608b1f9
commit
628bc92e66
15
checkenv.go
15
checkenv.go
@ -1,15 +0,0 @@
|
||||
// Please ignore this :))))))) :(
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
LookedupEnv := os.LookupEnv("SEGFAUTILITiES_PORT")
|
||||
if LookedupEnv === false {
|
||||
fmt.Println("haha")
|
||||
}
|
||||
fmt.Println(os.Getenv("SEGFAUTILITIES_PORT"))
|
||||
}
|
4
main.go
4
main.go
@ -4,6 +4,8 @@ import (
|
||||
"net/http"
|
||||
"html/template"
|
||||
"io"
|
||||
"log"
|
||||
"github.com/ProjectSegfault/segfautilities/otherthings"
|
||||
)
|
||||
|
||||
type StaticThingy struct {
|
||||
@ -11,6 +13,8 @@ type StaticThingy struct {
|
||||
}
|
||||
|
||||
func main() {
|
||||
log.Println("[Segfautilities] Starting")
|
||||
otherthings.CheckEnv()
|
||||
tmpl := template.Must(template.ParseFiles("static/index.html"))
|
||||
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
data := StaticThingy{
|
||||
|
21
otherthings/checkenv.go
Normal file
21
otherthings/checkenv.go
Normal file
@ -0,0 +1,21 @@
|
||||
// Please ignore this :))))))) :(
|
||||
package otherthings
|
||||
|
||||
import (
|
||||
"os"
|
||||
"log"
|
||||
)
|
||||
|
||||
var unused string
|
||||
var ok1 bool
|
||||
|
||||
func CheckEnv() {
|
||||
unused, ok1 = os.LookupEnv("SEGFAUTILITIES_PORT")
|
||||
if ok1 {
|
||||
log.Println("[Segfautilities] Environment variable SEGFAUTILITIES_PORT is set as " + unused)
|
||||
} else {
|
||||
log.Fatal("[Segfautilities] Environment variable SEGFAUTILITIES_PORT is not set! Please set it to a number, for example 6893")
|
||||
}
|
||||
|
||||
log.Println("[Segfautilities] ✅ Passed the Environment Variables check")
|
||||
}
|
Reference in New Issue
Block a user