Reviewed-on: phoenix/twilio_sender#4 Co-authored-by: kdeng00 <kundeng00@pm.me> Co-committed-by: kdeng00 <kundeng00@pm.me>
32 lines
530 B
Go
32 lines
530 B
Go
package config
|
|
|
|
import "encoding/json"
|
|
import "fmt"
|
|
import "os"
|
|
|
|
import (
|
|
"git.kundeng.us/phoenix/twilio_sender/models"
|
|
)
|
|
|
|
func ParseConfig(filepath string) (config models.TwiloDetails, success bool) {
|
|
content, err := os.ReadFile(filepath)
|
|
|
|
fmt.Println("Reading config file...")
|
|
fmt.Printf("%s\n", filepath)
|
|
|
|
if err != nil {
|
|
fmt.Println("An error reading the file")
|
|
|
|
return
|
|
}
|
|
|
|
err = json.Unmarshal(content, &config)
|
|
|
|
if err != nil {
|
|
fmt.Println("An error occurred")
|
|
return config, false
|
|
}
|
|
|
|
return config, true
|
|
}
|