Skip to content

Instantly share code, notes, and snippets.

View travisjeffery's full-sized avatar

Travis Jeffery travisjeffery

View GitHub Profile
@travisjeffery
travisjeffery / dep.md
Last active October 23, 2019 10:39
Fixing golang/dep's "unable to update checked out version" issue

If you're using golang/dep, and for an unexplained reason running dep ensure errors:

unable to update checked out version: : command failed: [git checkout 019ae5ada31de202164b118aee88ee2d14075c31]: exit status 1

You have to remove the dep from your Gopkg.lock file. This way Gopkg won't look for the missing ref.

And then dep ensure again.

// error.go
// assert Error implements the error interface.
var _ error = &Error{}
// Error implements the error interface.
func (e *Error) Error() string {
b := new(bytes.Buffer)
e.printStack(b)
pad(b, ": ")
// error.go
// WrapErr returns a corev1.Error for the given error and msg.
func WrapErr(err error, msg string) error {
if err == nil {
return nil
}
e := &Error{Message: fmt.Sprintf("%s: %s", msg, err.Error())}
e.populateStack()
return e
type AppError struct {
Error Error
Message string
Code int
}
/path/main.go:20: github.com/travisjeffery/example.c:
/path/main.go:16: ...b:
/path/main.go:12: ...a: shit's on fire, yo
// example.proto
service Users {
rpc GetUser (GetUserRequest) returns (GetUserResponse) {}
}
message GetUserResponse {
User user = 1;
Error error = 2;
}
// transport.go
r.Methods("GET").Handle("/users/{id}", httptransport.NewServer(
endpoints.GetUserEndpoint,
decodeGetUserRequest,
encodeResponse,
options...,
))
type errorer interface {
// endpoints.go
func makeGetUserEndpoint(userService user.Service) endpoint.Endpoint {
return func(ctx context.Context, request interface{}) (interface{}, error) {
req := request.(*GetUserRequest)
user, err := userService.GetUser(req.User)
if err != nil {
return &GetUserResponse{Error: err.(*Error)}, nil
}
return &GetUserResponse{User: user}, nil
// example.proto
service Users {
rpc GetUser (GetUserRequest) returns (GetUserResponse) {}
}
message GetUserResponse {
User user = 1;
Error error = 2;
}
// stack.go
type Stack struct {
Callers []uintptr
}
func (t Stack) Marshal() ([]byte, error) {
return nil, nil
}