This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package contacts | |
type Person struct { | |
FirstName string | |
LastName string | |
FavoriteNumber int | |
} | |
func Me() *Person { | |
return &Person{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package app | |
import "contacts" | |
func GreatSpeaker() *Person { | |
return contacts.Me() | |
} | |
func TestMyName(t *testing.T) { | |
got := GreatSpeaker() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package contacts | |
type Person struct { | |
FirstName string | |
LastName string | |
} | |
func Me() *Person { | |
return &Person{ | |
FirstName: "Ross", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::convert::AsRef; | |
use std::ffi::OsStr; | |
#[derive(Clone, Debug)] | |
#[must_use = "join_args is lazy and does nothing unless consumed"] | |
pub struct JoinArgs<A, B> { | |
a: A, | |
b: B, | |
state: JoinState, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Conn struct { | |
wc io.WriteCloser | |
cancel context.CancelFunc | |
tasks sync.WaitGroup | |
// ... other internal state ... | |
} | |
func NewConn(rwc io.ReadWriteCloser) *Conn { | |
ctx, cancel := context.WithCancel(context.Background()) | |
c := &Conn{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ctxReader adds timeouts and cancellation to a reader. | |
type ctxReader struct { | |
r io.Reader | |
ctx context.Context // set to change Context | |
// internal state | |
result chan readResult | |
pos, n int | |
err error | |
buf [1024]byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// writeCtx writes bytes to a writer while making a best effort to | |
// respect the Done signal of the Context. However, once any bytes have | |
// been written to w, writeCtx will ignore the Done signal to avoid | |
// partial writes. | |
func writeCtx(ctx context.Context, w io.Writer, b []byte) (int, error) { | |
select { | |
case <-ctx.Done(): | |
// Early cancel. | |
return 0, ctx.Err() | |
default: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Conn struct { | |
wc io.WriteCloser | |
tasks sync.WaitGroup | |
// ... other internal state ... | |
} | |
func NewConn(rwc io.ReadWriteCloser) *Conn { | |
c := &Conn{wc: rwc} | |
c.tasks.Add(1) | |
go func() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Conn struct { | |
wc io.WriteCloser | |
// ... other internal state ... | |
} | |
func NewConn(rwc io.ReadWriteCloser) *Conn { | |
c := &Conn{wc: rwc} | |
go c.receive(rwc) | |
return c | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Users/light/go/src/archive/tar/format.go:131:26: unnecessary conversion | |
/Users/light/go/src/archive/tar/strconv.go:198:34: unnecessary conversion | |
/Users/light/go/src/archive/tar/strconv.go:200:30: unnecessary conversion | |
/Users/light/go/src/archive/zip/reader.go:303:18: unnecessary conversion | |
/Users/light/go/src/debug/dwarf/entry.go:419:15: unnecessary conversion | |
/Users/light/go/src/math/big/prime.go:253:14: unnecessary conversion | |
/Users/light/go/src/net/http/fs.go:292:17: unnecessary conversion | |
/Users/light/go/src/net/http/h2_bundle.go:6966:37: unnecessary conversion | |
/Users/light/go/src/net/writev_unix.go:81:23: unnecessary conversion | |
/Users/light/go/src/os/stat_darwin.go:45:24: unnecessary conversion |