Browse Source

Rename variables to more idiomatic Go

pull/533/head
4 years ago committed by xpetit
parent
commit
fe9da2d9f5
  1. 4
      go/tests/balancedstring_test/balancedstring_correct/main.go
  2. 4
      go/tests/flags_test/main.go
  3. 8
      go/tests/split_test/main.go
  4. 4
      subjects/fixthemain.en.md
  5. 9
      subjects/go-reloaded/go-reloaded.en.md
  6. 2
      subjects/isalpha.en.md
  7. 2
      subjects/islower.en.md
  8. 2
      subjects/isnumeric.en.md
  9. 2
      subjects/isprintable.en.md
  10. 2
      subjects/isupper.en.md
  11. 7
      subjects/printwordstables.en.md
  12. 5
      subjects/splitwhitespaces.en.md
  13. 7
      subjects/strlen.en.md

4
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' {

4
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,

8
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)
}
}

4
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)
}
}

9
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"))
}
```

2
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 {
}
```

2
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 {
}
```

2
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 {
}
```

2
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 {
}
```

2
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 {
}
```

7
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)
}
```

5
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?"))
}
```

7
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)
}
```

Loading…
Cancel
Save