Skip to content

Instantly share code, notes, and snippets.

View TheHippo's full-sized avatar
🦛

Philipp Klose TheHippo

🦛
View GitHub Profile
@TheHippo
TheHippo / prepare-commit-msg
Last active July 13, 2016 14:26
If your git branch starts with a number add `ref #ISSUE-NUMBER` to commit msg
#!/bin/bash
NAME=$(git branch | grep '*' | sed 's/* //')
ISSUE_NUMBER=$(git branch | grep '*' | sed 's/* //' | tr -dc '0-9')
if [ "$2" == "message" ]; then
echo "Message given, we do not modify the git commit message"
exit 0
fi
if [ "$2" == "merge" ] || [ "$2" == "squash" ]; then
echo "$2 commit, we do not edit the message"
exit 0
@TheHippo
TheHippo / pre-commit
Last active May 6, 2020 16:48
`goimports` pre-commit hook
#!/bin/sh
# Copyright 2012 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# git goimports pre-commit hook
#
# To use, store as .git/hooks/pre-commit inside your repository and make sure
# it has execute permissions.
#
@TheHippo
TheHippo / Makefile
Created March 31, 2016 22:32
Golang Makefile example
OUT := binariy-name
PKG := gitlab.com/group/project
VERSION := $(shell git describe --always --long --dirty)
PKG_LIST := $(shell go list ${PKG}/... | grep -v /vendor/)
GO_FILES := $(shell find . -name '*.go' | grep -v /vendor/)
all: run
server:
go build -i -v -o ${OUT} -ldflags="-X main.version=${VERSION}" ${PKG}
@TheHippo
TheHippo / main.go
Created August 15, 2015 02:22
Benchmarking Go Mutex overhead
package main
import (
"fmt"
"sync"
)
type unlocked struct {
i int
}