Skip to content

Instantly share code, notes, and snippets.

View NaniteFactory's full-sized avatar
😊
Hi

NaniteFactory

😊
Hi
View GitHub Profile
@jrnewell
jrnewell / go-path.cmd
Last active May 22, 2018 10:25
Set current directory to GOPATH on MS Windows cmd
@echo off
goto START
-------------------------------------------------------
go-path.bat
set the GOPATH to current directory
Created Sat May 3 20:00:00 2014
@thekarel
thekarel / gcd.go
Created April 11, 2015 22:10
GCD in go
package main
import (
"fmt"
"math"
)
func gcd(a, b int) int {
for b != 0 {
rem := math.Mod(float64(a), float64(b))
@joyrexus
joyrexus / README.md
Created February 23, 2015 22:11
boltdb demo
package lpcwstr
// #include <windows.h>
// #include <wchar.h>
// #include <WinNT.h>
import "C"
import (
"unicode/utf16"
"unsafe"
@montanaflynn
montanaflynn / proxy.go
Last active January 17, 2021 15:37
Golang reverse proxy
package main
import (
"log"
"net/http"
"net/http/httputil"
)
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
@pokstad
pokstad / gaereverseproxy.go
Last active October 24, 2021 09:35
Google App Engine reverse proxy in Golang
// Copyright 2011 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.
// HTTP reverse proxy handler
package goengine
import (
"io"
@flaviocopes
flaviocopes / check-substring-ends-with.go
Last active November 15, 2021 09:34
Go: check if a string ends with a substring #golang
package main
import (
"strings"
)
func main() {
strings.HasSuffix("foobar", "bar") // true
}
@liubin
liubin / cookie.go
Created June 4, 2013 12:44
display cookie in go lang
@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}
@cuixin
cuixin / json_to_map.go
Created October 25, 2017 01:53
json to map[string]interface{} example in golang
package main
import (
"encoding/json"
"fmt"
)
func dumpMap(space string, m map[string]interface{}) {
for k, v := range m {
if mv, ok := v.(map[string]interface{}); ok {