Skip to content

Instantly share code, notes, and snippets.

//usr/bin/env go run $0 -- "$@"; exit $?
package main
import "os"
func writeStringToFile(path string, s string) error {
file, err := os.Create(path)
if err != nil {
return err
}
package main
import "os"
func makeDirectoryIfNotExists(path string) error {
if _, err := os.Stat(path); os.IsNotExist(err) {
return os.Mkdir(path, os.ModeDir|0755)
}
return nil
}
#
# Without arguments:
#
#!/bin/bash -ex
main()
{
#
}
#!/bin/bash -ex
usage()
{
local PROG_NAME=`basename $0`
echo "Usage: $PROG_NAME params"
}
main()
{
program_exists () {
type "$1" &> /dev/null ;
}
if ! program_exists foo; then
echo "Please install foo"
exit 2
fi
# Bash compare strings
if [ "$x" = "valid" ]; then
echo "x has the value 'valid'"
fi
if [ "$x" != "valid" ]; then
echo "x has the value 'valid'"
fi
//usr/bin/env go run $0 -- "$@"; exit $?
//
// Use this script to maintain a set of github gists as files.
//
// Usage:
// - install 'gist' program (https://github.com/defunkt/gist)
// - make sure you have Go (https://golang.org) installed
// - make a folder somewhere where you want to store your gists.
// - place gist-update.go (https://gist.github.com/ivanzoid/611177bbd3f5cb0604810f07080757b3#file-gist-update-go) to this folder
package main
import (
"os/exec"
"strings"
"fmt"
)
func runProgram1(program string, args ...string) (string, error) {
outStrings, err := runProgram(program, args...)
package main
import (
"os"
"bufio"
)
func readFirstLineFromFile(path string) (string, error) {
file, err := os.Open(path)
if err != nil {