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 ( | |
| "reflect" | |
| "testing" | |
| ) | |
| func BenchmarkMapsEqualsManual(b *testing.B) { | |
| m1 := newMap() | |
| m2 := newMap() |
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
| controller('MainCtrl', function( | |
| $window, | |
| $location | |
| ){ | |
| this.switch = function() { | |
| $location.path('/alt' === $location.path() ? '/' : '/alt'); | |
| }; | |
| }); |
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 "testing" | |
| type Stuff struct { | |
| Hello string | |
| Goodbye string | |
| Slice []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
| import ( | |
| "fmt" | |
| "reflect" | |
| "strings" | |
| ) | |
| type ToStringer struct { | |
| pieces []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 "testing" | |
| type Foo struct { | |
| } | |
| func (f *Foo) Hi() { | |
| } |
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
| // helper methods for testing | |
| package test | |
| import ( | |
| "fmt" | |
| "path/filepath" | |
| "runtime" | |
| "testing" | |
| ) |
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
| for _, foo := range foos { | |
| // is there a valid reason for ever taking the address of a | |
| // variable written to by range? | |
| process(&foo) | |
| } |
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
| #!/bin/bash | |
| while :; do | |
| run_something # we want to run this thing until it fails | |
| if [[ "$?" -ne "0" ]] | |
| then | |
| # we detected a failure, quit | |
| exit | |
| fi | |
| 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
| query := req.URL.Query() | |
| query.Set("user_id", 1) | |
| req.URL.RawQuery = query.Encode() |
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" | |
| "net/http" | |
| ) | |
| func main() { | |
| http.HandleFunc("/microservices", func(w http.ResponseWriter, r *http.Request) { | |
| fmt.Fprintf(w, "lol no\n") |