Go
Adding filename:
package main
import "fmt"
func main() { fmt.Println("hello world")}
package main
import "fmt"
type base struct { num int}
func (b base) describe() string { return fmt.Sprintf("base with num=%v", b.num)}
type container struct { base str string}
func main() {
co := container{ base: base{ num: 1, }, str: "some name", }
fmt.Printf("co={num: %v, str: %v}\n", co.num, co.str)
fmt.Println("also num:", co.base.num)
fmt.Println("describe:", co.describe())
type describer interface { describe() string }
var d describer = co fmt.Println("describer:", d.describe())}
Highlighting certain lines:
package main
import ( "fmt" "time")
func main() {
c1 := make(chan string, 1) go func() { time.Sleep(2 * time.Second) c1 <- "result 1" }()
select { case res := <-c1: fmt.Println(res) case <-time.After(1 * time.Second): fmt.Println("timeout 1") }
c2 := make(chan string, 1) go func() { time.Sleep(2 * time.Second) c2 <- "result 2" }() select { case res := <-c2: fmt.Println(res) case <-time.After(3 * time.Second): fmt.Println("timeout 2") }}