Skip to content

Instantly share code, notes, and snippets.

View johanbrandhorst's full-sized avatar

Johan Brandhorst-Satzkorn johanbrandhorst

View GitHub Profile
@johanbrandhorst
johanbrandhorst / db.go
Last active August 29, 2021 16:25
Missing nullable enums in sqlc v1.9.0
//// Code generated by sqlc. DO NOT EDIT.
package tutorial
import (
"context"
"database/sql"
)
type DBTX interface {

Keybase proof

I hereby claim:

  • I am johanbrandhorst on github.
  • I am jbrandhorst (https://keybase.io/jbrandhorst) on keybase.
  • I have a public key whose fingerprint is 06EB 47D9 1147 57E2 9DC9 D155 266C 7D9B 44EA A057

To claim this, I am signing this object:

@johanbrandhorst
johanbrandhorst / upload.go
Last active December 14, 2022 23:16
Multipart form uploads in Go
package upload
func Upload(w http.ResponseWriter, req *http.Request) {
defer req.Body.Close()
// Write straight to disk
err := req.ParseMultipartForm(0)
if err != nil {
http.Error(w, err.Error(), http.StatusBadRequest)
return
# Install protoc, protoc-gen-govalidators
protoc my.proto --govalidators_out=gogoimport=true,Mgoogle/protobuf/empty.proto=github.com/gogo/protobuf/types,Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:./ -I/usr/local/include -I./
# Install protoc
# Left as exercise to reader
# Install protoc-gen-gogo and friends
go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/jsonpb
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/gogoproto
protoc ./my/my.proto --gogo_out=:./ -I./ -I.$GOPATH/src
# Install protoc
# Left as exercise to reader
# Install protoc-gen-gogo and friends
go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/jsonpb
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/gogoproto
protoc ./my/my.proto --gogo_out=:./ -I./ -I.$GOPATH/src
# Install protoc
# Left as exercise to reader
# Install protoc-gen-gogo and friends
go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/jsonpb
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/gogoproto
protoc ./my/my.proto --gogo_out=:./ -I./ -I.$GOPATH/src
@johanbrandhorst
johanbrandhorst / generate.sh
Created October 4, 2016 13:28
Unexpected warnings from protoc-gen-gogo
# Install protoc
# Left as exercise to reader
# Install protoc-gen-gogo and friends
go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/jsonpb
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/gogoproto
# Generate level3 file
@johanbrandhorst
johanbrandhorst / generate.sh
Last active October 4, 2016 11:55
Generate invalid timestamp code
# Install protoc3. Left as exercise to reader
# Install protoc-gen-gogo and friends
go get github.com/gogo/protobuf/proto
go get github.com/gogo/protobuf/jsonpb
go get github.com/gogo/protobuf/protoc-gen-gogo
go get github.com/gogo/protobuf/gogoproto
# Generate file
protoc my.proto --gogo_out=Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types:./ -I./ -I$GOPATH/src