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 "C" | |
| import ( | |
| "fmt" | |
| "runtime" | |
| "sync" | |
| "syscall" | |
| "unsafe" | |
| ) |
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 error | |
| import pkgerrors "github.com/pkg/errors" | |
| // FromPanicValue returns an error with the best possible stack-trace from | |
| // the value obtained from calling recover() within a defer | |
| func FromPanicValue(pv any) error { | |
| if pv == nil { | |
| return nil | |
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
| Input Hostname Protocol Path Query | |
| "<h1>hi there</h1>" <h1>hi there</h1> | |
| "" | |
| " " | |
| "$ whoami" $ whoami | |
| "not a url" not a url | |
| "???" ?? | |
| "?://???" ://??? | |
| " ? " | |
| " why?? : ; /" why ? : ; / |
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
| export type Operation<T, E = Error> = typeof NotStarted | typeof Waiting | Complete<T> | Failed<E>; | |
| export enum OperationState { | |
| NotStartedState = "NotStarted", | |
| WaitingState = "Waiting", | |
| CompleteState = "Complete", | |
| FailedState = "Failed", | |
| } | |
| export const NotStarted = { |
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 | |
| # | |
| # Usage: bash count_functions_loc.sh some/directory | |
| set -euo pipefail | |
| main() { | |
| for f in $(find $1 -name '*.go' -not -name 'test_*.go'); do | |
| count_funcs < "$f" | awk "{ print \"$f\", \$1, \$2 }" | |
| 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
| # Gets an int between min max inclusive very inefficiently, but | |
| # only using bash built-ins. More inefficient the smaller the gap | |
| # | |
| # usage: n=$( bad_random_int 1000 2000 ) | |
| bad_random_int() { | |
| local min=$1 | |
| local max=$2 | |
| local n=0 | |
| while [[ "$n" -lt "$min" ]] || [[ "$n" -gt "$max" ]]; do |
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" | |
| func main() { | |
| type person struct { | |
| nickname string | |
| } | |
| ppl := []person{ |
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
| // Let's define a type with a method that needs a fair few arguments | |
| type Thing struct {} | |
| func (c *Thing) Verb(a A,b B,c C,d D) {} | |
| // We have things that depend on Thing and we want to test them, so to mock it we'll need to | |
| // define an interface and generate a mock | |
| type Thinger interface { | |
| Verb(a A,b B,c C,d D) | |
| } |
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
| SOURCE="github.com/you/thing" | |
| FORK="github.com/other/thing" | |
| PACKAGE="some-package" | |
| CONSTRAINT="aabbcc" | |
| dep ensure -add ${SOURCE}/${PACKAGE}:${FORK}.git@${CONSTRAINT} |
NewerOlder