mirror of
https://github.com/hanzoai/tsgo.git
synced 2026-10-30 19:37:15 +00:00
103 lines
1.7 KiB
Plaintext
103 lines
1.7 KiB
Plaintext
package emptycase
|
|
|
|
var X int
|
|
|
|
func Switch() {
|
|
switch X {
|
|
case 1:
|
|
~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case 2:
|
|
~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case 3:
|
|
~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case 4:
|
|
println(`oops`)
|
|
}
|
|
}
|
|
|
|
func SwitchCommented() {
|
|
switch X {
|
|
case 1:
|
|
// do nothing
|
|
case 2:
|
|
~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case 3:
|
|
~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case 4:
|
|
println(`oops`)
|
|
}
|
|
}
|
|
|
|
func SwitchSingleCase() {
|
|
switch X {
|
|
case 1:
|
|
~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
}
|
|
}
|
|
|
|
func SwitchDefaultCase() {
|
|
switch X {
|
|
case 1:
|
|
~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
default:
|
|
~~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
}
|
|
}
|
|
|
|
var (
|
|
ch = make(chan int)
|
|
ch2 = make(chan int)
|
|
ch3 = make(chan int)
|
|
ch4 = make(chan int)
|
|
)
|
|
|
|
func Select() {
|
|
select {
|
|
case <-ch:
|
|
~~~~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case <-ch2:
|
|
~~~~~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case <-ch3:
|
|
~~~~~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
case <-ch4:
|
|
println(`oops`)
|
|
}
|
|
}
|
|
|
|
func SelectCommented() {
|
|
select {
|
|
case <-ch:
|
|
// do nothing
|
|
}
|
|
}
|
|
|
|
func SelectSingleCase() {
|
|
select {
|
|
case <-ch:
|
|
~~~~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
}
|
|
}
|
|
|
|
func SelectDefaultCase() {
|
|
select {
|
|
case x := <-ch:
|
|
println(x)
|
|
default:
|
|
~~~~~~~~
|
|
!!! emptycase: this case block is empty and will do nothing
|
|
}
|
|
}
|
|
|