Skip to content

Commit d4aae3c

Browse files
committed
Change coding standard
1 parent 2da1ce2 commit d4aae3c

File tree

6 files changed

+23
-23
lines changed

6 files changed

+23
-23
lines changed

ansible/ansible.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ func New(commandFactory command.Factory) *Ansible {
2525
func (ansible *Ansible) Install(osName, sudoPassword string) (err error) {
2626
var installed bool
2727

28-
if installed, err = ansible.isInstalled(); nil != err {
28+
if installed, err = ansible.isInstalled(); err != nil {
2929
return err
3030
}
3131

32-
if false == installed {
32+
if !installed {
3333
switch osName {
3434
case "oracle-linux":
3535
commands := []*command.Command{
@@ -53,12 +53,12 @@ func (ansible *Ansible) Install(osName, sudoPassword string) (err error) {
5353
}
5454

5555
printer.Printf("\n<comment>$ %s</comment>\n", commands[2].String())
56-
if err = commands[2].Run(); nil != err {
56+
if err = commands[2].Run(); err != nil {
5757
return err
5858
}
5959

6060
printer.Printf("\n<comment>$ %s</comment>\n", commands[3].String())
61-
if err = commands[3].Run(); nil != err {
61+
if err = commands[3].Run(); err != nil {
6262
return err
6363
}
6464
default:
@@ -88,7 +88,7 @@ func (ansible *Ansible) RunAnsiblePlaybook(playbookFilePath, variableFilePath, s
8888
}
8989

9090
printer.Printf("\n<comment>$ %s</comment>\n", cmd.String())
91-
if err = cmd.Run(); nil != err {
91+
if err = cmd.Run(); err != nil {
9292
return err
9393
}
9494

@@ -99,13 +99,13 @@ func (ansible *Ansible) isInstalled() (installed bool, err error) {
9999
var path string
100100
var realPath string
101101

102-
if path, err = ansible.commandFactory.NewCommand("which", "ansible").Output(); nil != err && "exit status 1" != err.Error() {
102+
if path, err = ansible.commandFactory.NewCommand("which", "ansible").Output(); err != nil && "exit status 1" != err.Error() {
103103
return false, err
104104
}
105105
path = strings.TrimSpace(path)
106106

107-
if "" != path {
108-
if realPath, err = ansible.commandFactory.NewCommand("ls", path).Output(); nil != err {
107+
if path != "" {
108+
if realPath, err = ansible.commandFactory.NewCommand("ls", path).Output(); err != nil {
109109
return false, err
110110
}
111111

command/argument.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func (arg *argument) ToString(hideSecret bool) string {
1515
return "***secret***"
1616
}
1717

18-
if strings.Contains(arg.Value, " ") || strings.Contains(arg.Value, "\"") {
18+
if strings.Contains(arg.Value, " ") || strings.Contains(arg.Value, `"`) {
1919
return fmt.Sprintf(`"%s"`, strings.ReplaceAll(arg.Value, `"`, `\"`))
2020
}
2121

hosts/hosts.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func IsHostsChanged(comment, newHostsFilePath, systemHostsFilePath string) (chan
2121
if _, oldHostsBuff, err = loadHostsFile(systemHostsFilePath, startMessage, endMessage); err != nil {
2222
return changed, err
2323
}
24-
if newHosts, err = os.ReadFile(newHostsFilePath); nil != err {
24+
if newHosts, err = os.ReadFile(newHostsFilePath); err != nil {
2525
return changed, err
2626
}
2727

@@ -42,7 +42,7 @@ func UpdateHostsFile(comment, newHostsFilePath, systemHostsFilePath string) (err
4242
return err
4343
}
4444

45-
if newHosts, err = os.ReadFile(newHostsFilePath); nil != err {
45+
if newHosts, err = os.ReadFile(newHostsFilePath); err != nil {
4646
return err
4747
}
4848

@@ -66,7 +66,7 @@ func loadHostsFile(filepath, startMessage, endMessage string) (buff bytes.Buffer
6666
}
6767

6868
var file *os.File
69-
if file, err = os.Open(filepath); nil != err {
69+
if file, err = os.Open(filepath); err != nil {
7070
return buff, oldBuff, err
7171
}
7272

@@ -90,7 +90,7 @@ func loadHostsFile(filepath, startMessage, endMessage string) (buff bytes.Buffer
9090
continue
9191
}
9292

93-
if (false == hasStart && false == hasEnd) || (true == hasStart && true == hasEnd) {
93+
if (!hasStart && !hasEnd) || (hasStart && hasEnd) {
9494
buff.WriteString(line)
9595
buff.WriteRune('\n')
9696
} else {
@@ -99,7 +99,7 @@ func loadHostsFile(filepath, startMessage, endMessage string) (buff bytes.Buffer
9999
}
100100
}
101101

102-
if err = file.Close(); nil != err {
102+
if err = file.Close(); err != nil {
103103
return buff, oldBuff, err
104104
}
105105

uac/uac.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func PromptWithExtraArguments(messageFilePath string, maxWaitTime time.Duration,
2828
err := job()
2929
message := []byte("")
3030

31-
if nil != err {
31+
if err != nil {
3232
message = []byte(err.Error())
3333
}
3434

wsl/task.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ func CreateTaskForStartSystemd(distribution string) (err error) {
3232
}
3333
defer rootFolder.Release()
3434

35-
if false == hasSubFolder(rootFolder, taskFolderName) {
35+
if !hasSubFolder(rootFolder, taskFolderName) {
3636
if err = createSubFolder(rootFolder, taskFolderName); err != nil {
3737
log.Fatal(err)
3838
}
3939
}
4040

41-
if true == hasTask(rootFolder, taskPath) {
41+
if hasTask(rootFolder, taskPath) {
4242
if _, err = oleutil.CallMethod(rootFolder, "DeleteTask", taskPath, 0); err != nil {
4343
return err
4444
}
@@ -112,7 +112,7 @@ func getTaskService() (service *ole.IDispatch, err error) {
112112
return nil, err
113113
}
114114

115-
if nil == scheduler {
115+
if scheduler == nil {
116116
ole.CoUninitialize()
117117
return nil, errors.New("could not create ITaskService instance")
118118
}
@@ -170,7 +170,7 @@ func getUsername() (username string, err error) {
170170
parts := strings.Split(currentUser.Username, `\`)
171171

172172
if len(parts) > 0 {
173-
if 1 == len(parts) {
173+
if len(parts) == 1 {
174174
return parts[0], nil
175175
} else {
176176
return parts[1], nil

wsl/wsl.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func EnableSystemd(distribution string) (err error) {
7070
var terminateResult string
7171

7272
if terminateResult, err = command.New("wsl", "--terminate", distribution).Output(); err != nil {
73-
if "The operation completed successfully." != strings.TrimSpace(terminateResult) {
73+
if strings.TrimSpace(terminateResult) != "The operation completed successfully." {
7474
return err
7575
}
7676
}
@@ -101,18 +101,18 @@ func updateWslConfFile(distribution, content string) (modified bool, err error)
101101
return modified, err
102102
}
103103

104-
if false == cfg.HasSection("boot") {
104+
if !cfg.HasSection("boot") {
105105
if _, err = cfg.NewSection("boot"); err != nil {
106106
return modified, err
107107
}
108108
}
109109

110-
if false == cfg.Section("boot").HasKey("systemd") {
110+
if !cfg.Section("boot").HasKey("systemd") {
111111
if _, err = cfg.Section("boot").NewKey("systemd", "true"); err != nil {
112112
return modified, err
113113
}
114114
modified = true
115-
} else if "true" != cfg.Section("boot").Key("systemd").Value() {
115+
} else if cfg.Section("boot").Key("systemd").Value() != "true" {
116116
cfg.Section("boot").Key("systemd").SetValue("true")
117117
modified = true
118118
}

0 commit comments

Comments
 (0)