Skip to content

Instantly share code, notes, and snippets.

@AmirSoleimani
AmirSoleimani / main.go
Last active January 10, 2023 08:18
Pub/Sub Pattern Golang
package main
import (
"patternsample/mq"
"fmt"
"time"
)
func main() {
@rayrutjes
rayrutjes / detectcontenttype.go
Created December 12, 2015 13:36
golang detect content type of a file
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
// Only the first 512 bytes are used to sniff the content type.
buffer := make([]byte, 512)
_, err = file.Read(buffer)
if err != nil {
@onjin
onjin / docker
Created July 12, 2013 08:19
/etc/init.d/docker file for debian
#!/bin/sh
# https://launchpad.net/~dotcloud/+archive/lxc-docker/+packages
### BEGIN INIT INFO
# Provides: docker
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: autofs $network $named alsa-utils pulseaudio
# Should-Stop: autofs $network $named alsa-utils pulseaudio
# Default-Start: 2 3 4 5
@arikfr
arikfr / example.go
Last active December 17, 2015 06:48
Safe shutdown in Go.
package main
import (
"log"
"shutdown"
)
func main() {
ch := shutdown.Add("test")
ch2 := shutdown.Add("test2")
@spikebike
spikebike / client.go
Created March 29, 2012 01:13
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)