This file contains hidden or 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
func GetKeyURL(x int) (*url.URL, error) { | |
y := Foo(x)? | |
z := Bar(y)? | |
return Baz(z) | |
} | |
func Foo(x int) (int, error) { | |
... | |
} |
This file contains hidden or 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 MyLongTypeName struct{ | |
... | |
} | |
func foo(x int, y string) (MyLongTypeName, error) { | |
if x == 42 { | |
return MyLongTypeName{}, errors.New("x cannot be the meaning of life") | |
} | |
if y == "" { |
This file contains hidden or 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 PrimaryColour int | |
const ( | |
Red = iota | |
Yellow | |
Blue | |
) | |
func (c PrimaryColour) String() string { | |
switch c { |
This file contains hidden or 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
func run(ctx context.Context) error { | |
var h Handler | |
ctx, cancel := context.WithCancel(ctx) | |
eg, ctx := errgroup.WithContext(ctx) | |
eg.Go(func() error { return h.Run(ctx) }) | |
eg.Go(func() error { | |
for i := 0; i < 10; i++ { | |
select { |
This file contains hidden or 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
func run(ctx context.Context) error { | |
var h Handler | |
ctx, cancel := context.WithCancel(ctx) | |
var wg sync.WaitGroup | |
wg.Add(1) | |
go func() { | |
h.Run(ctx) | |
wg.Done() |
This file contains hidden or 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
func run(ctx context.Context) error { | |
var h Handler | |
h.Start(ctx) | |
defer h.Close() | |
for i := 0; i < 10; i++ { | |
select { | |
case <-time.After(time.Second): | |
log.Print(h.GetVal()) | |
case <-ctx.Done(): |
This file contains hidden or 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::collections::LinkedList; | |
fn main() { | |
let mut list: LinkedList<u32> = LinkedList::new(); | |
list.push_back(2); | |
list.push_back(3); | |
list.push_back(5); | |
list.push_back(7); | |
list.push_back(11); |
This file contains hidden or 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 main | |
import ( | |
"fmt" | |
"container/list" | |
) | |
func main() { | |
l := list.New() | |
l.PushBack(2) |
This file contains hidden or 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 main | |
import ( | |
"encoding/json" | |
"errors" | |
"flag" | |
"fmt" | |
"io/ioutil" | |
"os" | |
) |
This file contains hidden or 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
class AppClient: | |
def __init__(self, app_addr): | |
self._app_addr = app_addr | |
def request(self, method, path): | |
return requests.request(method, f"{self._app_addr}{path}") | |
@pytest.fixture(scope="function") | |
def app_client(app): |
NewerOlder