Skip to content

Instantly share code, notes, and snippets.

View badcock4412's full-sized avatar
⛰️
Erecting monuments

Ben Adcock badcock4412

⛰️
Erecting monuments
View GitHub Profile
@badcock4412
badcock4412 / main.go
Last active April 2, 2020 17:10
How to capture username and password from a terminal session in golang (cross-platform)
// adapted from the "best" solution supplied by StackExchange user gihanchanuka:
// https://stackoverflow.com/questions/2137357/getpasswd-functionality-in-go
//
// Tested in Windows Powershell and Windows cmd
package main
import (
"bufio"
"fmt"
@badcock4412
badcock4412 / main.go
Last active July 6, 2021 12:53
Sample golang web server returning JSON objects
package main
import (
"encoding/json"
"log"
"net/http"
"strconv"
)
func ServeJSON(rw http.ResponseWriter, obj interface{}) {