- Go Concurrency Patterns: Context
- Package context
- Context
- Context is for cancelation
- Context isn’t for cancellation
- Revisiting context and http.Handler for Go 1.7
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/apex/go-apex" | |
"github.com/apex/go-apex/kinesis" | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/firehose" | |
) |
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 ( | |
"fmt" | |
"reflect" | |
) | |
func main() { | |
a := []int{1, 2, 3, 4} |
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
#!/bin/bash -e | |
# Usage ./k8s-service-account-kubeconfig.sh ( namespace ) ( service account name ) | |
TEMPDIR=$( mktemp -d ) | |
trap "{ rm -rf $TEMPDIR ; exit 255; }" EXIT | |
SA_SECRET=$( kubectl get sa -n $1 $2 -o jsonpath='{.secrets[0].name}' ) |
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 ( | |
"os" | |
"io/ioutil" | |
"time" | |
"golang.org/x/crypto/ssh" | |
"net" | |
"golang.org/x/crypto/ssh/agent" | |
"crypto/rsa" |
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
/* | |
Copyright 2016 Alex Smolen (https://alexsmolen.com) | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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 genStruct() gopter.Gen { | |
return genStrucType().FlatMap( | |
func(arg interface{}) gopter.Gen { | |
// typ := arg.(reflect.Type) | |
// Q: How to construct a generator? | |
return nil | |
}, | |
reflect.TypeOf((interface{})(nil)), | |
) | |
} |
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 equilib | |
// Indices returns any of the equilibrium indices, -1 if there is not one | |
func Indices(nums []int) int { | |
if len(nums) > 10 { | |
return -2 | |
} | |
for i := 0; i < len(nums); i++ { | |
left := sum(nums[0:i]) | |
right := sum(nums[i+1:]) |
An introduction to curl
using GitHub's API.
Makes a basic GET request to the specifed URI
curl https://api.github.com/users/caspyin