Skip to content

Instantly share code, notes, and snippets.

View Northern-Lights's full-sized avatar

Northern-Lights

  • Area 1 Security
View GitHub Profile
@Northern-Lights
Northern-Lights / json_interface.go
Created March 15, 2019 23:00
JSON unmarshaling when a struct contains an interface field
// https://play.golang.org/p/l_GmjX31XbM
package main
import (
"encoding/json"
"fmt"
)
// Main has a Field2 whose type we don't know at the time of unmarshaling. We
@Northern-Lights
Northern-Lights / channel-fill-close-recv.go
Created February 1, 2019 21:48
What happens when you fill a channel, close it, then try to recv?
// Q: What happens when you fill a channel, close it, then try to recv?
// A: You can keep reading the values until the buffer is empty, then
// the close operation takes effect
package main
import (
"fmt"
"time"
)
@Northern-Lights
Northern-Lights / gotk-glade-test.go
Created November 24, 2018 17:25
How to use Glade UI builder in a Go/golang GTK application using gotk
package main
import (
"fmt"
"log"
"os"
"reflect"
"github.com/gotk3/gotk3/glib"
@Northern-Lights
Northern-Lights / rsa.go
Created September 5, 2017 01:27
Go: get public/private key from id_rsa PEM file
import (
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"github.com/Northern-Lights/going/file"
)
// LoadPrivate loads an (unencrypted) RSA private key from PEM data
func LoadPrivate(filepath string) (*rsa.PrivateKey, error) {