Skip to content

Commit b05ac66

Browse files
committed
quick comments and small fixes
1 parent b28ac02 commit b05ac66

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

internal/greeting/greeting.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"github.com/riotpot/internal/cli"
1010
)
1111

12+
// TODO: Walktrhough is no longer something needed. The greeting should be something small and fast.
13+
1214
type Greet struct {
1315
// Indicates if this is the first time riotpot has been launched
1416
Tutorial bool
@@ -30,6 +32,7 @@ func (g *Greet) Greeting() {
3032
}
3133

3234
// Gives a walkthrough RiotPot
35+
3336
func (g *Greet) walkthrough() {}
3437

3538
// Throws a regular salute

pkg/models/models.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ package models
55

66
import "time"
77

8+
// TODO: This should be in the database package
9+
810
// schema for test cases
911
type Test_model struct {
1012
Timestamp string

tools/environ/netcheck.go

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,37 +4,40 @@ Package environ provides functions used to interact with the environment
44
package environ
55

66
import (
7-
"net"
87
"log"
8+
"net"
99
)
1010

1111
/*
1212
Check if the port on the host machine is busy or not
1313
this is used for plugins to play on the host
1414
*/
15+
// TODO: change the hardcoded address of the host. At the very least get it from the configuration
1516
func CheckPortBusy(protocol string, port string) bool {
17+
// Whether we can connect to some port
1618
conn, err := net.Listen(protocol, "localhost:"+port)
19+
isbusy := err != nil
1720

18-
if err != nil {
19-
return false
21+
if isbusy {
22+
conn.Close()
2023
}
2124

22-
conn.Close()
23-
return true
25+
return isbusy
2426
}
2527

2628
// check if the IP address is valid
2729
func CheckIPAddress(ip string) bool {
28-
if net.ParseIP(ip) == nil {
29-
log.Fatalf("IP Address: %s - Invalid\n", ip)
30-
return false
31-
} else {
32-
return true
33-
}
30+
isvalid := net.ParseIP(ip) != nil
31+
32+
if !isvalid {
33+
log.Fatalf("Invalid IP %s", ip)
34+
}
35+
36+
return isvalid
3437
}
3538

3639
// check if IP address is reachable via ping command
3740
func CheckIPConnection(IP string) {
3841
path := GetPath("ping")
3942
ExecuteCmd(path, IP, "-c", "2")
40-
}
43+
}

0 commit comments

Comments
 (0)