mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-05 13:10:07 +00:00
chore: cleanup some code (#1069)
* chore * modernize loop * ddns: simpify Provider struct
This commit is contained in:
@@ -8,21 +8,11 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ErrGjsonNotFound = errors.New("specified path does not exist")
|
||||
ErrGjsonWrongType = errors.New("wrong type")
|
||||
)
|
||||
|
||||
var emptyIterator = func(yield func(string, string) bool) {}
|
||||
|
||||
func GjsonGet(json []byte, path string) (gjson.Result, error) {
|
||||
result := gjson.GetBytes(json, path)
|
||||
if !result.Exists() {
|
||||
return result, ErrGjsonNotFound
|
||||
}
|
||||
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func GjsonIter(json string) (iter.Seq2[string, string], error) {
|
||||
if json == "" {
|
||||
return emptyIterator, nil
|
||||
|
||||
Reference in New Issue
Block a user