This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
package main | |
import ( | |
"fmt" | |
"sort" | |
"sync" | |
"testing" | |
"time" | |
) |
This is inspired by A half-hour to learn Rust and Zig in 30 minutes.
Your first Go program as a classical "Hello World" is pretty simple:
First we create a workspace for our project:
package main | |
import ( | |
"os" | |
"exec" | |
) | |
func pipe_commands(commands ...*exec.Cmd) ([]byte, os.Error) { | |
for i, command := range commands[:len(commands) - 1] { | |
out, err := command.StdoutPipe() | |
if err != nil { |
package main | |
import ( | |
"bytes" | |
"fmt" | |
"io/ioutil" | |
"log" | |
"golang.org/x/crypto/ssh" | |
kh "golang.org/x/crypto/ssh/knownhosts" |
package main | |
import ( | |
"bufio" | |
"io/ioutil" | |
"os/signal" | |
//"syscall" | |
"fmt" | |
"log" | |
"os" |
package main | |
import ( | |
"bufio" | |
"io/ioutil" | |
"os/signal" | |
//"syscall" | |
"fmt" | |
"log" | |
"os" |
git config --global credential.modalPrompt false |
```go | |
func isNil(i interface{}) bool { | |
return i == nil || reflect.ValueOf(i).IsNil() | |
} | |
``` | |
better: | |
```go | |
func isNilFixed(i interface{}) bool { |
package main | |
import ( | |
"flag" | |
"fmt" | |
"log" | |
"os" | |
"runtime/pprof" | |
"strconv" | |
"sync" |
# human readable /proc/net/netstat | |
# https://sa-chernomor.livejournal.com/9858.html | |
cat /proc/net/netstat | \ | |
awk '(f==0) { i=1; while ( i<=NF) {n[i] = $i; i++ }; f=1; next} \ | |
(f==1){ i=2; while ( i<=NF){ printf "%s = %d\n", n[i], $i; i++}; f=0} ' |