MCPcopy
hub / github.com/luk4z7/go-concurrency-guide / locale

Function locale

patterns/contextpackage/cancel/main.go:78–91  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

76}
77
78func locale(ctx context.Context) (string, error) {
79 if deadline, ok := ctx.Deadline(); ok {
80 if deadline.Sub(time.Now().Add(1*time.Minute)) <= 0 {
81 return "", context.DeadlineExceeded
82 }
83 }
84
85 select {
86 case <-ctx.Done():
87 return "", ctx.Err()
88 case <-time.After(1 * time.Minute):
89 }
90 return "EN/US", nil
91}

Callers 2

genGreetingFunction · 0.85
genFarewellFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected