move some stuff around

This commit is contained in:
2026-07-24 21:11:33 -07:00
parent 0064294c3c
commit 98c8b453a0
3 changed files with 36 additions and 28 deletions
+28
View File
@@ -0,0 +1,28 @@
package main
import (
"encoding/json"
"fmt"
"os"
)
type Config struct {
URL string `json:"url"`
Username string `json:"username"`
Password string `json:"password"`
}
var serverConfig Config
func read_config() {
file, err := os.ReadFile("config.json")
if err != nil {
fmt.Print(err.Error())
return
}
err = json.Unmarshal(file, &serverConfig)
if err != nil {
fmt.Print(err.Error())
}
}
+8
View File
@@ -0,0 +1,8 @@
package main
import "strings"
func convert_username_into_url(username string) string {
result := strings.ReplaceAll(username, "@", "%40")
return result
}
-28
View File
@@ -1,41 +1,13 @@
package main package main
import ( import (
"encoding/json"
"fmt" "fmt"
"io" "io"
"log" "log"
"net/http" "net/http"
"os"
"strings" "strings"
) )
type Config struct {
URL string `json:"url"`
Username string `json:"username"`
Password string `json:"password"`
}
var serverConfig Config
func read_config() {
file, err := os.ReadFile("config.json")
if err != nil {
fmt.Print(err.Error())
return
}
err = json.Unmarshal(file, &serverConfig)
if err != nil {
fmt.Print(err.Error())
}
}
func convert_username_into_url(username string) string {
result := strings.ReplaceAll(username, "@", "%40")
return result
}
func main() { func main() {
read_config() read_config()