From fe9da2d9f58f3e6d9bd6dd3678cebf281c5fd062 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=81=A3?= <⁣> Date: Sun, 17 May 2020 11:58:47 +0200 Subject: [PATCH] Rename variables to more idiomatic Go --- .../balancedstring_test/balancedstring_correct/main.go | 4 ++-- go/tests/flags_test/main.go | 4 ++-- go/tests/split_test/main.go | 8 ++++---- subjects/fixthemain.en.md | 4 ++-- subjects/go-reloaded/go-reloaded.en.md | 9 ++++----- subjects/isalpha.en.md | 2 +- subjects/islower.en.md | 2 +- subjects/isnumeric.en.md | 2 +- subjects/isprintable.en.md | 2 +- subjects/isupper.en.md | 2 +- subjects/printwordstables.en.md | 7 +++---- subjects/splitwhitespaces.en.md | 5 ++--- subjects/strlen.en.md | 7 +++---- 13 files changed, 27 insertions(+), 31 deletions(-) diff --git a/go/tests/balancedstring_test/balancedstring_correct/main.go b/go/tests/balancedstring_test/balancedstring_correct/main.go index 92623c66..ae540cd7 100644 --- a/go/tests/balancedstring_test/balancedstring_correct/main.go +++ b/go/tests/balancedstring_test/balancedstring_correct/main.go @@ -5,9 +5,9 @@ import ( "os" ) -func solve(str string) int { +func solve(s string) int { var count, countC, countD int - for _, r := range str { + for _, r := range s { if r == 'C' { countC++ } else if r == 'D' { diff --git a/go/tests/flags_test/main.go b/go/tests/flags_test/main.go index d2a0aa11..c6b19288 100644 --- a/go/tests/flags_test/main.go +++ b/go/tests/flags_test/main.go @@ -12,7 +12,7 @@ type node struct { } func main() { - str := []string{"--insert=", "--order"} + s := []string{"--insert=", "--order"} strShorthand := []string{"-i=", "-o"} var randflag []string var randflagarg []string @@ -22,7 +22,7 @@ func main() { } node := &node{ - flags: str, + flags: s, flagsShorthand: strShorthand, randArgFlag: randflagarg, randArg: randflag, diff --git a/go/tests/split_test/main.go b/go/tests/split_test/main.go index fc27ea98..95a794fd 100644 --- a/go/tests/split_test/main.go +++ b/go/tests/split_test/main.go @@ -20,7 +20,7 @@ func main() { "[<>abc<>]"} type node struct { - str string + s string sep string } table := []node{} @@ -29,16 +29,16 @@ func main() { for i := 0; i < 15; i++ { separator := separators[rand.Intn(len(separators))] val := node{ - str: strings.Join(lib.MultRandAlnum(), separator), + s: strings.Join(lib.MultRandAlnum(), separator), sep: separator, } table = append(table, val) } table = append(table, - node{str: "HelloHAhowHAareHAyou?", sep: "HA"}) + node{s: "HelloHAhowHAareHAyou?", sep: "HA"}) for _, arg := range table { - lib.Challenge("Split", student.Split, strings.Split, arg.str, arg.sep) + lib.Challenge("Split", student.Split, strings.Split, arg.s, arg.sep) } } diff --git a/subjects/fixthemain.en.md b/subjects/fixthemain.en.md index 6f774d31..479f822f 100644 --- a/subjects/fixthemain.en.md +++ b/subjects/fixthemain.en.md @@ -9,8 +9,8 @@ Fix the following program. ```go package piscine -func PrintStr(str string) { - for _, r := range str { +func PrintStr(s string) { + for _, r := range s { z01.PrintRune(r) } } diff --git a/subjects/go-reloaded/go-reloaded.en.md b/subjects/go-reloaded/go-reloaded.en.md index 6c5c70da..7ad789d4 100644 --- a/subjects/go-reloaded/go-reloaded.en.md +++ b/subjects/go-reloaded/go-reloaded.en.md @@ -425,7 +425,7 @@ The separators are spaces, tabs and newlines. ### Expected function ```go -func SplitWhiteSpaces(str string) []string { +func SplitWhiteSpaces(s string) []string { } ``` @@ -443,8 +443,7 @@ import ( ) func main() { - str := "Hello how are you?" - fmt.Println(student.SplitWhiteSpaces(str)) + fmt.Println(student.SplitWhiteSpaces("Hello how are you?")) } ``` @@ -492,8 +491,8 @@ import ( ) func main() { - str := "HelloHAhowHAareHAyou?" - fmt.Println(student.Split(str, "HA")) + s := "HelloHAhowHAareHAyou?" + fmt.Println(student.Split(s, "HA")) } ``` diff --git a/subjects/isalpha.en.md b/subjects/isalpha.en.md index 6fefc896..ca8f8e27 100644 --- a/subjects/isalpha.en.md +++ b/subjects/isalpha.en.md @@ -7,7 +7,7 @@ Write a function that returns `true` if the `string` passed in parameter only co ### Expected function ```go -func IsAlpha(str string) bool { +func IsAlpha(s string) bool { } ``` diff --git a/subjects/islower.en.md b/subjects/islower.en.md index 1e4ebd06..30964010 100644 --- a/subjects/islower.en.md +++ b/subjects/islower.en.md @@ -7,7 +7,7 @@ Write a function that returns `true` if the `string` passed in parameter only co ### Expected function ```go -func IsLower(str string) bool { +func IsLower(s string) bool { } ``` diff --git a/subjects/isnumeric.en.md b/subjects/isnumeric.en.md index ff88e7c0..083714cb 100644 --- a/subjects/isnumeric.en.md +++ b/subjects/isnumeric.en.md @@ -7,7 +7,7 @@ Write a function that returns `true` if the `string` passed in parameter only co ### Expected function ```go -func IsNumeric(str string) bool { +func IsNumeric(s string) bool { } ``` diff --git a/subjects/isprintable.en.md b/subjects/isprintable.en.md index 599592ce..a5626963 100644 --- a/subjects/isprintable.en.md +++ b/subjects/isprintable.en.md @@ -7,7 +7,7 @@ Write a function that returns `true` if the `string` passed in parameter only co ### Expected function ```go -func IsPrintable(str string) bool { +func IsPrintable(s string) bool { } ``` diff --git a/subjects/isupper.en.md b/subjects/isupper.en.md index 1fe7432e..22d009a6 100644 --- a/subjects/isupper.en.md +++ b/subjects/isupper.en.md @@ -7,7 +7,7 @@ Write a function that returns `true` if the `string` passed in parameter only co ### Expected function ```go -func IsUpper(str string) bool { +func IsUpper(s string) bool { } ``` diff --git a/subjects/printwordstables.en.md b/subjects/printwordstables.en.md index 3a06a5ca..31183a9f 100644 --- a/subjects/printwordstables.en.md +++ b/subjects/printwordstables.en.md @@ -9,7 +9,7 @@ Each word is on a single line (each word ends with a `\n`). ### Expected function ```go -func PrintWordsTables(table []string) { +func PrintWordsTables(a []string) { } ``` @@ -24,9 +24,8 @@ package main import piscine ".." func main() { - str := "Hello how are you?" - table := piscine.SplitWhiteSpaces(str) - piscine.PrintWordsTables(table) + a := piscine.SplitWhiteSpaces("Hello how are you?") + piscine.PrintWordsTables(a) } ``` diff --git a/subjects/splitwhitespaces.en.md b/subjects/splitwhitespaces.en.md index 13dffb31..70771680 100644 --- a/subjects/splitwhitespaces.en.md +++ b/subjects/splitwhitespaces.en.md @@ -9,7 +9,7 @@ The separators are spaces, tabs and newlines. ### Expected function ```go -func SplitWhiteSpaces(str string) []string { +func SplitWhiteSpaces(s string) []string { } ``` @@ -27,8 +27,7 @@ import ( ) func main() { - s := "Hello how are you?" - fmt.Printf("%#v\n", piscine.SplitWhiteSpaces(s)) + fmt.Printf("%#v\n", piscine.SplitWhiteSpaces("Hello how are you?")) } ``` diff --git a/subjects/strlen.en.md b/subjects/strlen.en.md index bea50067..3d07e83d 100644 --- a/subjects/strlen.en.md +++ b/subjects/strlen.en.md @@ -7,7 +7,7 @@ ### Expected function ```go -func StrLen(str string) int { +func StrLen(s string) int { } ``` @@ -25,9 +25,8 @@ import ( ) func main() { - str := "Hello World!" - nb := piscine.StrLen(str) - fmt.Println(nb) + l := piscine.StrLen("Hello World!") + fmt.Println(l) } ```