Skip to content

Instantly share code, notes, and snippets.

View davewalk's full-sized avatar
💭
test

Dave Walk davewalk

💭
test
  • Philadelphia, PA
View GitHub Profile
@davewalk
davewalk / custom_unmarshal.go
Created March 4, 2016 18:57
Custom unmarhsaling of JSON example
package main
import (
"encoding/json"
"fmt"
)
type Record struct {
SiteId string `json:"site_id"`
JsonData interface{} `json:"json_data"`
@davewalk
davewalk / interface_slice.go
Created April 4, 2016 16:27
Go empty interface value that is actually of type []string to a comma-separated string
package main
import (
"encoding/json"
"fmt"
"reflect"
"strings"
)
type Product struct {
@davewalk
davewalk / profiling.go
Created May 3, 2016 21:14
Spin up a pprof web server and print some RAM stats too
_ "net/http/pprof"
go func() {
for _ = range time.Tick(time.Duration(10) * time.Second) {
fmt.Printf("Number of goroutines: %d\n", runtime.NumGoroutine())
var m runtime.MemStats
runtime.ReadMemStats(&m)
fmt.Printf("heap in use: %v\n", m.HeapInuse)
fmt.Printf("heap alloc: %v\n", m.HeapAlloc)
fmt.Printf("next GC: %v\n", m.NextGC)
@davewalk
davewalk / go_projects_april17.md
Created April 11, 2017 00:12
Interesting Go projects that perhaps you'll like (April 2017)