github.com/amarpal/go-tools@v0.0.0-20240422043104-40142f59f616/staticcheck/sa1019/testdata/src/example.com/CheckDeprecated_go18/CheckDeprecated.go (about) 1 package pkg 2 3 import ( 4 "compress/flate" 5 "crypto/x509" 6 "database/sql/driver" 7 "net/http" 8 "os" 9 "syscall" 10 ) 11 12 var _ = syscall.StringByteSlice("") //@ diag(`Use ByteSliceFromString instead`) 13 14 func fn1(err error) { 15 var r http.Request 16 var rp *http.Request 17 _ = r.Cancel //@ diag(re`deprecated since Go 1\.7:.+If a Request's Cancel field and context are both`) 18 _ = rp.Cancel //@ diag(re`deprecated since Go 1\.7:.+If a Request's Cancel field and context are both`) 19 _ = syscall.StringByteSlice("") //@ diag(`Use ByteSliceFromString instead`) 20 _ = os.SEEK_SET //@ diag(`Use io.SeekStart, io.SeekCurrent, and io.SeekEnd`) 21 _ = os.SEEK_CUR //@ diag(`Use io.SeekStart, io.SeekCurrent, and io.SeekEnd`) 22 _ = os.SEEK_END //@ diag(`Use io.SeekStart, io.SeekCurrent, and io.SeekEnd`) 23 if err == http.ErrWriteAfterFlush { //@ diag(`ErrWriteAfterFlush is no longer`) 24 println() 25 } 26 var _ flate.ReadError //@ diag(`No longer returned`) 27 28 var tr *http.Transport 29 tr.CancelRequest(nil) //@ diag(`CancelRequest has been deprecated`) 30 31 var conn driver.Conn 32 conn.Begin() //@ diag(`Begin has been deprecated`) 33 34 _ = x509.CertificateRequest{}.Attributes //@ diag(`x509.CertificateRequest{}.Attributes has been deprecated since Go 1.5 and an alternative has been available since Go 1.3:`) 35 } 36 37 // Deprecated: Don't use this. 38 func fn2() { 39 _ = syscall.StringByteSlice("") 40 41 anon := func(x int) { 42 println(x) 43 _ = syscall.StringByteSlice("") 44 45 anon := func(x int) { 46 println(x) 47 _ = syscall.StringByteSlice("") 48 } 49 anon(2) 50 } 51 anon(1) 52 }