- stage 1: You believe you can make Go do object oriented programming. You want to do this by using clever struct embedding.
- stage 2: You believe goroutines will solve all of your problems. You want to use goroutines for anything and everything that you can, who cares if the code becomes a bit more complicated
- stage 3: You believe that instead of object oriented programming, interfaces will solve all of your problems. You want to define everything in terms of interfaces
- stage 4: You believe channels will solve all of your problems. You want to do everything from synchronization, returning values, and flow control using channels.
- stage 5: You now believe Go is not as powerful as people claim it to be. You feel like you're stripped of all of the nice tools and constructs that other languages provide.
- stage 6: You realize that stages 1~5 were all just your imagination. You just didn't want to accept the Go way. Everything starts to make sense.
- stage 7: You are now at peace
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
# App Engine Standard Go 1.9 migration to Go 1.11 | |
tag:["google-app-engine", "Go"] | |
Migrating from Go 1.9 to 1.11 in App Engine Standard isn't just a matter of updating Go itself - | |
it introduces a major update in the runtime itelf. Because of this, you can't just change your | |
code to work on Go 1.11 and expect it to be deployed properly. You will need to work on a few | |
more issues. | |
This article describes the new runtime known as the Google App Engine Standard 2nd Gen, |
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 | |
set -e | |
# Script to configure the healthcheck for ESP | |
# (ESP listens on a separate port from the main port for healthchecks) | |
SERVICE_NAME="This the name of your service that you proxy your requests to" | |
ESP_HEALTH_CHECK_PORT_NAME="This is the name of the port that ESP listens for health checks." | |
ESP_MAIN_PORT_NAME="This is the name of the port that ESP listens for the actual service." |
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
use strict; | |
use JSON (); | |
my $src = qx(gcloud compute forwarding-rules list --format json); | |
my $json = JSON->new; | |
my $rules = $json->decode( $src ); | |
for my $rule (@$rules) { | |
print "forwarding-rule $rule->{name}:\n"; | |
if ($rule->{description} =~ m{kubernetes\.io/service-name}) { # TCP (k8s Service with external address) | |
my ($target_pool) = ($rule->{target} =~ m{/([^/]+)$}); |
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
// Wrap the handler with a context that holds the transaction | |
func withTx(h http.Handler) http.Handler { | |
return http.HandleFunc(func(w http.ResponseWriter, r *http.Request) { | |
tx, err := globalDB.BeginTx(r.Context()) | |
if err != nil { | |
http.Error(...) | |
return | |
} | |
r = r.WithContext(context.WithTx(r.Context(), tx)) | |
h.ServeHTTP(w, r) |
- Jeff Dean
- Daniel Bernstein
- Gary Bernhardt https://www.destroyallsoftware.com/talks/the-birth-and-death-of-javascript
- Rich Hickey https://www.infoq.com/presentations/Simple-Made-Easy
- Bret Victor https://vimeo.com/36579366
- Jake Archibald https://www.youtube.com/watch?v=cmGr0RszHc8
- John Wilkes (Borg guy)
- Martin Fowler
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
use strict; | |
use feature 'say'; | |
sub is_anagram { | |
my ($s1, $s2) = @_; | |
my %chars1; | |
my %chars2; | |
for my $c (split //, $s1) { | |
$chars1{$c}++; |
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 ( | |
"flag" | |
"fmt" | |
"io" | |
"log" | |
"os" | |
"runtime/pprof" | |
"sync" |
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 TestParallelBatch(t *testing.T) { | |
dir, err := ioutil.TempDir("", "leveldb-test-") | |
if !assert.NoError(t, err, "ioutil.TempDir should succeed") { | |
return | |
} | |
defer os.RemoveAll(dir) | |
db, err := leveldb.OpenFile(dir, nil) | |
if !assert.NoError(t, err, "leveldb.OpenFile should succeed") { | |
return |
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" | |
"log" | |
"math/rand" | |
"os" | |
"os/signal" | |
"sync" |