Skip to content

Commit

Permalink
Move the main function to cmd directory (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mstmdev authored Oct 8, 2023
1 parent 47966c3 commit 0758cee
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
9 changes: 9 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

import (
"github.com/no-src/hosts"
)

func main() {
hosts.PrintHosts()
}
9 changes: 3 additions & 6 deletions main.go → hosts.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main
package hosts

import (
"os"
Expand All @@ -10,15 +10,12 @@ import (
"github.com/no-src/log"
)

func main() {
printHosts()
}

func isWindows() bool {
return runtime.GOOS == "windows"
}

func printHosts() {
// PrintHosts print the hosts info
func PrintHosts() {
hostsFile := "/etc/hosts"
if isWindows() {
sysRoot := os.Getenv("SYSTEMROOT")
Expand Down
4 changes: 2 additions & 2 deletions hosts_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package main
package hosts

import "testing"

func TestPrintHosts(t *testing.T) {
printHosts()
PrintHosts()
}

0 comments on commit 0758cee

Please sign in to comment.