Skip to content

Instantly share code, notes, and snippets.

@diyan
diyan / go_http_clients.md
Last active October 14, 2019 08:11
Go HTTP clients. Sample code in two common use-cases

Go HTTP clients. Sample code in common use-cases

  • Use case #1: Work with JSON using strings, make a HTTP POST
  • Use case #2: Work with JSON using structs, make a HTTP POST

Describe how to change various HTTP request attributes that usually differs from one request to another:

  • HTTP headers
  • Request timeout
  • TODO query string parameters
@iamralch
iamralch / compress.go
Last active April 16, 2023 03:04
ZIP archives in Golang
import (
"archive/zip"
"io"
"os"
"path/filepath"
"strings"
)
func zipit(source, target string) error {
zipfile, err := os.Create(target)
@alobato
alobato / start-stop-example.sh
Created March 3, 2012 23:09
start-stop-example
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
@chrisfarms
chrisfarms / xmlparser.go
Created November 18, 2011 17:59
Really rough example of using xml.Parser
package main
import (
"fmt";
"io"
"xml"
"strings"
)