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 Dog struct { | |
| bark string | |
| } | |
| func (d *Dog) Bark() string { | |
| return d.bark | |
| } | |
| func (d Dog) Bark() string { | |
| return d.bark |
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 Animal struct { | |
| } | |
| type Dog struct { | |
| } | |
| type Boxer struct { | |
| Animal | |
| Dog | |
| } |
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 TestReverse(t *testing.T) { | |
| tests := []struct { | |
| s string | |
| r string | |
| name string | |
| }{ | |
| {"aha", "aha", "3 letter palindrome"}, | |
| {"guy", "yug", "my name"}, | |
| } |
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 TestReverse(t *testing.T) { | |
| tests := []struct { | |
| s string | |
| r string | |
| }{ | |
| {"aha", "aha"}, | |
| {"guy", "yug"}, | |
| } | |
| for _, tc := range tests { |
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 Reverse(s string) string { | |
| var b strings.Builder | |
| for i := len(s) - 1; i >= 0; i-- { | |
| b.Write([]byte{s[i]}) | |
| } | |
| return b.String() | |
| } |
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 ( | |
| "net/http" | |
| "github.com/sirupsen/logrus" | |
| ) | |
| func main() { | |
| mux := http.NewServeMux() |
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 main() { | |
| log := logrus.New() | |
| apiCall := DelegateConn(log, "scheme://path/to/resource") | |
| body := []byte("content") | |
| _ = apiCall(body) | |
| } | |
| func DelegateConn(log *logrus.Logger, url string) func([]byte) error { | |
| client := New(url) |
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
| { | |
| "ignition": { | |
| "version": "3.2.0" | |
| }, | |
| "passwd": { | |
| "users": [ | |
| { | |
| "groups": [ | |
| "wheel", | |
| "plugdev" |
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 ( | |
| "context" | |
| "fmt" | |
| "sync" | |
| ) | |
| func main() { | |
| ctx := context.Background() |
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 main() { | |
| log := log15.New() | |
| mux := http.NewServeMux() | |
| mux.Handle("/profile", | |
| Chain( | |
| log, | |
| profileHandler(log), | |
| Auth("user", "password"), | |
| LogAccess, | |
| ), |
NewerOlder