mirror of
https://gitea.com/gitea/runner.git
synced 2026-08-26 13:57:46 +00:00
chore: update deps, adapt lint, use json v2 (#1185)
- Raised go to 1.27 - Adopted json v2 - Sync lint config from gitea - Fixed all issues Co-authored-by: silverwind <me@silverwind.io> Reviewed-on: https://gitea.com/gitea/runner/pulls/1185 Reviewed-by: bircni <bircni@icloud.com> Co-authored-by: Renovate Bot <renovate-bot@gitea.com>
This commit is contained in:
@@ -4,7 +4,8 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"encoding/json/jsontext"
|
||||
"encoding/json/v2"
|
||||
"os"
|
||||
)
|
||||
|
||||
@@ -31,7 +32,7 @@ func LoadRegistration(file string) (*Registration, error) {
|
||||
defer f.Close()
|
||||
|
||||
var reg Registration
|
||||
if err := json.NewDecoder(f).Decode(®); err != nil {
|
||||
if err := json.UnmarshalRead(f, ®); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -49,7 +50,9 @@ func SaveRegistration(file string, reg *Registration) error {
|
||||
|
||||
reg.Warning = registrationWarning
|
||||
|
||||
enc := json.NewEncoder(f)
|
||||
enc.SetIndent("", " ")
|
||||
return enc.Encode(reg)
|
||||
if err := json.MarshalWrite(f, reg, jsontext.WithIndent(" ")); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = f.WriteString("\n")
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user