Skip to content

Commit

Permalink
Refactor code to remove unnecessary package and unused imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradumnasaraf committed Sep 12, 2024
1 parent fa27f01 commit c0d5f72
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/golang/concepts/12) slices2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "fmt"
func main() {
// remove an element from a slice
var cars = []string{"BMW", "Audi", "Mercedes", "Ford", "Fiat"}

fmt.Println(cars)
var index int = 2
// We are concatenating two slice and rewriting the 1st Slice.
Expand Down
2 changes: 1 addition & 1 deletion docs/golang/concepts/33) channels-open.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ func main() {
wg.Done()

}(myChannel, wg)

wg.Wait()
}
10 changes: 5 additions & 5 deletions docs/golang/introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,11 @@ A method is a function with a special receiver argument. The receiver appears in

1. **Value Receiver**: It is used when we don't want to modify the original value.

> func (t Test) printName() { fmt.Println(t.Name) }
> `func (t Test) printName() { fmt.Println(t.Name) }`
2. **Pointer Receiver**: It is used when we want to modify the original value.

> func (t *Test) printName() { fmt.Println(t.Name) }
> `func (t *Test) printName() { fmt.Println(t.Name) }`
Here's what a receiver does:

Expand Down Expand Up @@ -665,16 +665,16 @@ func main() {
fmt.Println("Hello")
}()
}
```
``` -->
### Race Conditions
<!-- ### Race Conditions
Race Conditions occur when two or more goroutines access the same variable concurrently and at least one of the accesses is a write. It can lead to unpredictable results.
We can check whether there is a race condition in our code by using the `-race` flag.
```bash
$ go run --race main.go
go run --race main.go
```

To avoid the race condition we can use the `sync` package. We can use the `Mutex` type to lock the variable.
Expand Down

0 comments on commit c0d5f72

Please sign in to comment.