From 3afb72c96830fcb0a2442dc57a78762393a781f5 Mon Sep 17 00:00:00 2001 From: Anton Novojilov Date: Mon, 12 Feb 2024 15:12:04 +0300 Subject: [PATCH] [strutil] Code refactoring --- system/info_darwin.go | 4 ++-- system/user_darwin.go | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/system/info_darwin.go b/system/info_darwin.go index c9822f5c..c96bd59f 100644 --- a/system/info_darwin.go +++ b/system/info_darwin.go @@ -69,8 +69,8 @@ func GetOSInfo() (*OSInfo, error) { info := &OSInfo{} for _, line := range strings.Split(string(versionData), "\n") { - name := strutil.ReadField(line, 0, false, ":") - value := strutil.ReadField(line, 1, false, ":") + name := strutil.ReadField(line, 0, false, ':') + value := strutil.ReadField(line, 1, false, ':') value = strings.Trim(value, " \r\t\n") switch name { diff --git a/system/user_darwin.go b/system/user_darwin.go index 652a3a91..9ea77c15 100644 --- a/system/user_darwin.go +++ b/system/user_darwin.go @@ -53,20 +53,20 @@ func getUserInfo(name string) (*User, error) { for scanner.Scan() { line := scanner.Text() - field := strutil.ReadField(line, 0, false, ":") + field := strutil.ReadField(line, 0, false, ':') switch field { case "UniqueID": - user.UID, err = strconv.Atoi(strings.TrimSpace(strutil.ReadField(line, 1, false, ":"))) + user.UID, err = strconv.Atoi(strings.TrimSpace(strutil.ReadField(line, 1, false, ':'))) case "PrimaryGroupID": - user.GID, err = strconv.Atoi(strings.TrimSpace(strutil.ReadField(line, 1, false, ":"))) + user.GID, err = strconv.Atoi(strings.TrimSpace(strutil.ReadField(line, 1, false, ':'))) case "NFSHomeDirectory": user.HomeDir = strutil.ReadField( - strings.TrimSpace(strutil.ReadField(line, 1, false, ":")), - 0, false, " ", + strings.TrimSpace(strutil.ReadField(line, 1, false, ':')), + 0, false, ' ', ) case "UserShell": - user.Shell = strings.TrimSpace(strutil.ReadField(line, 1, false, ":")) + user.Shell = strings.TrimSpace(strutil.ReadField(line, 1, false, ':')) } if err != nil { @@ -93,7 +93,7 @@ func getGroupInfo(name string) (*Group, error) { group := &Group{Name: name} data := string(out) - group.GID, err = strconv.Atoi(strings.TrimSpace(strutil.ReadField(data, 1, false, ":"))) + group.GID, err = strconv.Atoi(strings.TrimSpace(strutil.ReadField(data, 1, false, ':'))) if err != nil { return nil, fmt.Errorf("Can't parse PrimaryGroupID field value: %v", err)