Skip to content

Commit

Permalink
fix(option): use local opt var instead for unmarshalling
Browse files Browse the repository at this point in the history
  • Loading branch information
dwisiswant0 committed Sep 2, 2023
1 parent 1667810 commit 13f1938
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 4 additions & 0 deletions option/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ func LoadFromJSONString(raw string) (teler.Options, error) {
// LoadFromJSONFile to unmarshal the teler-waf JSON
// configuration into the [teler.Options] struct.
func LoadFromJSONFile(path string) (teler.Options, error) {
var opt teler.Options

// Read the JSON file
jsonFile, err := readFile(path)
if err != nil {
Expand All @@ -57,6 +59,8 @@ func LoadFromYAMLString(raw string) (teler.Options, error) {
// LoadFromYAMLFile to unmarshal the teler-waf YAML
// configuration into the [teler.Options] struct.
func LoadFromYAMLFile(path string) (teler.Options, error) {
var opt teler.Options

// Read the YAML file
yamlFile, err := readFile(path)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions option/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ func readFile(path string) ([]byte, error) {
}

func unmarshalJSONBytes(raw []byte) (teler.Options, error) {
var opt teler.Options

// Unmarshal the JSON into the Options struct
err := json.Unmarshal(raw, &opt)
return opt, err
}

func unmarshalYAMLBytes(raw []byte) (teler.Options, error) {
var opt teler.Options

// Unmarshal the JSON into the Options struct
err := yaml.Unmarshal(raw, &opt)
return opt, err
Expand Down
10 changes: 0 additions & 10 deletions option/vars.go

This file was deleted.

0 comments on commit 13f1938

Please sign in to comment.