Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,4 @@
|
|||
func main() {
|
||||
inf:
|
||||
goto inf
|
||||
}
|
||||
18
Task/Flow-control-structures/Go/flow-control-structures-2.go
Normal file
18
Task/Flow-control-structures/Go/flow-control-structures-2.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import "os"
|
||||
|
||||
func processFile() {
|
||||
f, err := os.Open("file")
|
||||
if err != nil {
|
||||
// (probably do something with the error)
|
||||
return // no need to close file, it didn't open
|
||||
}
|
||||
defer f.Close() // file is open. no matter what, close it on return
|
||||
var lucky bool
|
||||
// some processing
|
||||
if (lucky) {
|
||||
// f.Close() will get called here
|
||||
return
|
||||
}
|
||||
// more processing
|
||||
// f.Close() will get called here too
|
||||
}
|
||||
16
Task/Flow-control-structures/Go/flow-control-structures-3.go
Normal file
16
Task/Flow-control-structures/Go/flow-control-structures-3.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func printOnes() {
|
||||
for {
|
||||
fmt.Println("1")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
go printOnes()
|
||||
for {
|
||||
fmt.Println("0")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
func answer(phone1, phone2 chan int) {
|
||||
select {
|
||||
case <-phone1:
|
||||
// talk on phone one
|
||||
case <-phone2:
|
||||
// talk on phone two
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue