Skip to content

Instantly share code, notes, and snippets.

View inancgumus's full-sized avatar

İnanç Gümüş inancgumus

View GitHub Profile
package main
import (
"fmt"
"time"
)
func main() {
// Sleep func let us stop the progress for a duration
//
package main
import "fmt"
func main() {
// has default type of float
const Tau = 3.14 * 2
// implicitly converted to a float64,
// because of the assignment to a "runtime" variable
@inancgumus
inancgumus / hilowconst.go
Last active October 8, 2017 15:38
high precision go consts
package main
import "fmt"
func main() {
// ------------------------------------------------
// LOSS OF PRECISION
// ------------------------------------------------
// const Pi lives in the ideal numbers universe which has at least 256-bit high-precision
package main
import (
"fmt"
)
func main() {
// if it was: 14000000000 it'll overflow int on 32-bit machines
// using the scientific notation 14e9, elects the variable's type as
// a float64. because, the scientific-notation is defined for floating nums
@inancgumus
inancgumus / age_of_universe_ok.go
Last active October 2, 2017 18:47
age of universe correct example
package main
import (
"fmt"
)
func main() {
// still not a good way to define a variable like this. we will see it.
var ageOfUniverse uint64 = 14e9 // 14e9 = 14 and 9 zeros which is 14 billions
@inancgumus
inancgumus / age_of_universe_overflow.go
Last active October 2, 2017 18:47
go ageOfUniverse overflows
package main
import (
"fmt"
)
// on 32-bit machines, it'll overflow
// on 64-bit machines, everything is fine
// use: uint64 instead.
func main() {
@inancgumus
inancgumus / sizeof.go
Created October 2, 2017 16:07
Go sizeof
package main
import (
"fmt"
"unsafe"
)
func main() {
var ageOfUniverse int
reservedBytes := unsafe.Sizeof(ageOfUniverse)
@inancgumus
inancgumus / http-benchmark.md
Created July 31, 2017 14:39 — forked from denji/http-benchmark.md
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@inancgumus
inancgumus / about.md
Created July 31, 2017 11:16 — forked from alexaandru/about.md
Minimal Golang web stack.

Mini Go Web Stack

Description

This represents a proof of concept, minimal web stack. I used http://nicolasmerouze.com/build-web-framework-golang/ series of articles as a starting point and the goal was to keep the stack as minimal as possible while still being useful for practical purposes. And of course, use the standard library as much as possible and only integrate components compatible with it.

@inancgumus
inancgumus / Golang-binary-versioning.md
Created July 27, 2017 11:15 — forked from rafecolton/Golang-binary-versioning.md
Copypasta for easy versioning for your Go binaries

Golang Binary Versioning Trick

To use, place the code in version_trick.go in your project. Don't forget to change the namespace to match yours to the actual name of your package.

In addition to version_trick.go, there's a makefile-snippet, that includes the secret sauce for making this trick work. Be sure to change the package name there as well.

Enjoy!

P.S. Special thanks to @meatballhat by way of @syscomet for showing me this trick!