github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/simple/s1037/testdata/src/example.com/CheckElaborateSleep/LintElaborateSleep.go (about)

     1  package pkg
     2  
     3  import (
     4  	"fmt"
     5  	"time"
     6  )
     7  
     8  func fn() {
     9  	time.Sleep(0)
    10  
    11  	select { //@ diag(`should use time.Sleep`)
    12  	case <-time.After(0):
    13  	}
    14  
    15  	select { //@ diag(`should use time.Sleep`)
    16  	case <-time.After(0):
    17  		fmt.Println("yay")
    18  	}
    19  
    20  	const d = 0
    21  	select { //@ diag(`should use time.Sleep`)
    22  	case <-time.After(d):
    23  	}
    24  
    25  	var ch chan int
    26  	select {
    27  	case <-time.After(0):
    28  	case <-ch:
    29  	}
    30  }