diff --git a/tests/go/prog/correct/fixthemain/main.go b/tests/go/prog/correct/fixthemain/main.go index 89205ba9..d4d3bf92 100644 --- a/tests/go/prog/correct/fixthemain/main.go +++ b/tests/go/prog/correct/fixthemain/main.go @@ -1,38 +1,33 @@ package main -import "github.com/01-edu/z01" +import "fmt" -const CLOSE = 0 -const OPEN = 1 +const ( + CLOSE = iota + OPEN +) type Door struct { State int } -func PrintStr(s string) { - for _, r := range s { - z01.PrintRune(r) - } - z01.PrintRune('\n') -} - func CloseDoor(ptrDoor *Door) { - PrintStr("Door Closing...") + fmt.Println("Door Closing...") ptrDoor.State = CLOSE } func OpenDoor(ptrdoor *Door) { - PrintStr("Door Opening...") + fmt.Println("Door Opening...") ptrdoor.State = OPEN } func IsDoorOpened(ptrDoor *Door) bool { - PrintStr("is the Door opened ?") + fmt.Println("is the Door opened ?") return ptrDoor.State == OPEN } func IsDoorClosed(ptrDoor *Door) bool { - PrintStr("is the Door closed ?") + fmt.Println("is the Door closed ?") return ptrDoor.State == CLOSE } diff --git a/tests/go/prog/correct/grouping/main.go b/tests/go/prog/correct/grouping/main.go index 9be334d7..93560058 100644 --- a/tests/go/prog/correct/grouping/main.go +++ b/tests/go/prog/correct/grouping/main.go @@ -45,10 +45,10 @@ func brackets(regexp, text string) { runes = runes[1 : len(runes)-1] result := simpleSearch(runes, text) for i, s := range result { - if !unicode.Is(unicode.Hex_Digit, s[len(s)-1]) { + if !unicode.Is(unicode.Hex_Digit, rune(s[len(s)-1])) { s = s[:len(s)-1] } - if !unicode.Is(unicode.Hex_Digit, s[0]) { + if !unicode.Is(unicode.Hex_Digit, rune(s[0])) { s = s[1:] } fmt.Printf("%d: %s\n", i+1, s) diff --git a/tests/go/prog/correct/isanagram/main.go b/tests/go/prog/correct/isanagram/main.go deleted file mode 100644 index dd7df09b..00000000 --- a/tests/go/prog/correct/isanagram/main.go +++ /dev/null @@ -1,23 +0,0 @@ -package main - -func IsAnagram(s, t string) bool { - alph := make([]int, 26) - for i := 0; i < len(s); i++ { - if s[i] < 'a' || s[i] > 'z' { - continue - } - alph[s[i]-'a']++ - } - for i := 0; i < len(t); i++ { - if t[i] < 'a' || t[i] > 'z' { - continue - } - alph[t[i]-'a']-- - } - for i := 0; i < 26; i++ { - if alph[i] != 0 { - return false - } - } - return true -} diff --git a/tests/go/prog/correct/pilot/main.go b/tests/go/prog/correct/pilot/main.go index 2fd76e10..1e52594c 100644 --- a/tests/go/prog/correct/pilot/main.go +++ b/tests/go/prog/correct/pilot/main.go @@ -1,17 +1,22 @@ package main -import ( - "fmt" +import "fmt" - student ".." -) +type Pilot struct { + Name string + Life float32 + Age int + Aircraft int +} -func main() { - var donnie student.Pilot - donnie.Name = "Donnie" - donnie.Life = 100.0 - donnie.Age = 24 - donnie.Aircraft = student.AIRCRAFT1 +const Aircraft1 = 1 +func main() { + donnie := Pilot{ + Name: "Donnie", + Life: 100.0, + Age: 24, + Aircraft: Aircraft1, + } fmt.Println(donnie) } diff --git a/tests/go/prog/correct/robottoorigin/main.go b/tests/go/prog/correct/robottoorigin/main.go index a0749dbc..90a1e630 100644 --- a/tests/go/prog/correct/robottoorigin/main.go +++ b/tests/go/prog/correct/robottoorigin/main.go @@ -1,6 +1,9 @@ package main -import "fmt" +import ( + "fmt" + "os" +) func solve(s string) bool { x := 0 @@ -22,7 +25,7 @@ func solve(s string) bool { } func main() { - if len(args) == 2 { - fmt.Println(solve(args[1])) + if len(os.Args) == 2 { + fmt.Println(solve(os.Args[1])) } } diff --git a/tests/go/prog/correct/switchcase/main.go b/tests/go/prog/correct/switchcase/main.go index f425f0d9..1caf09a1 100644 --- a/tests/go/prog/correct/switchcase/main.go +++ b/tests/go/prog/correct/switchcase/main.go @@ -9,13 +9,14 @@ import ( func main() { if len(os.Args) == 2 { s := os.Args[1] + runes := []rune(s) for i, r := range s { if unicode.IsLower(r) { - s[i] = unicode.ToUpper(r) + runes[i] = unicode.ToUpper(r) } else if unicode.IsUpper(r) { - s[i] = unicode.ToLower(r) + runes[i] = unicode.ToLower(r) } } - fmt.Println(s) + fmt.Println(string(runes)) } }