-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
219 additions
and
130 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package config | ||
|
||
// Config defines the structure for storing configuration values read from a YAML file. | ||
type Log struct { | ||
// directory where log files are stored | ||
DirLog string `yaml:"dirLog"` | ||
// maximum size of a log file, in megabytes | ||
FileSizeMB uint64 `yaml:"fileSizeInMb"` | ||
// number of records to show when | ||
APIShowRecords uint64 `yaml:"apiShowRecords"` | ||
} |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package core | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"gopkg.in/yaml.v2" | ||
) | ||
|
||
var ErrIncorectType = errors.New("incorrect types") | ||
|
||
//nolint | ||
func GetObjectFromMap[T any](objectMap any, unmarshalObject T) (T, error) { | ||
var objectBytes []byte | ||
|
||
var err error | ||
|
||
switch p := objectMap.(type) { | ||
case map[interface{}]interface{}: | ||
objectBytes, err = yaml.Marshal(p) | ||
default: | ||
return unmarshalObject, fmt.Errorf("%w for : %T", ErrIncorectType, p) | ||
} | ||
|
||
if err != nil { | ||
return unmarshalObject, fmt.Errorf("failed to marshal objectMap: %w", err) | ||
} | ||
|
||
err = yaml.Unmarshal(objectBytes, &unmarshalObject) | ||
if err != nil { | ||
return unmarshalObject, fmt.Errorf("failed to unmarshal output object: %w", err) | ||
} | ||
|
||
return unmarshalObject, nil | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.