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 main_test | |
import ( | |
"testing" | |
) | |
var x MultipleFieldStructure | |
type MultipleFieldStructure struct { | |
a int |
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
func main() { | |
var i int8 = 1 | |
read(i) | |
} | |
//go:noinline | |
func read(i interface{}) { | |
println(i) | |
} |
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
func main() { | |
var i int8 = 1 | |
read(i) | |
} | |
//go:noinline | |
func read(i interface{}) { | |
n := i.(int16) | |
println(n) | |
} |
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
log.SetOutput(os.Stdout) | |
log.WithFields(log.Fields{ | |
"url": "http://foo.com", | |
"attempt": 3, | |
"backoff": time.Second, | |
}).Info("failed to fetch URL") |
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
l := zerolog.New(zerolog.ConsoleWriter{Out: os.Stderr}) | |
l.Info(). | |
Str("url", `http://foo.com`). | |
Int("attempt", 3). | |
Dur("backoff", time.Second). | |
Msg("failed to fetch URL") |
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
logger.Info("failed to fetch URL", | |
// Structured context as strongly typed Field values. | |
zap.String("url", `http://foo.com`), | |
zap.Int("attempt", 3), | |
zap.Duration("backoff", time.Second), | |
) |
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 main | |
import ( | |
"log" | |
"os" | |
"github.com/urfave/cli" | |
) | |
func main() { | |
app := cli.NewApp() |
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 main | |
import ( | |
"github.com/spf13/cobra" | |
) | |
func main() { | |
cmd := newCommand() | |
cmd.AddCommand(newNestedCommand()) |
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 main | |
import ( | |
"context" | |
"flag" | |
"github.com/google/subcommands" | |
) | |
type GreetCommand struct {} | |
func (g *GreetCommand) Name() string { return "greet" } |
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 Command struct { | |
// Run runs the command. | |
// The args are the arguments after the command name. | |
Run func(cmd *Command, args []string) | |
// UsageLine is the one-line usage message. | |
// The first word in the line is taken to be the command name. | |
UsageLine string | |
// Short is the short description shown in the 'go help' output. |