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" | |
| "syscall" | |
| "unsafe" | |
| ) | |
| const ( | |
| SCHED_NORMAL = iota |
| // Author : Sandesh Bhusal | |
| // Date Feb 23, 2021 | |
| // You may copy, download and modify the source code according to your requirements :) | |
| // Happy Spoofing! | |
| // Original Code Lives at https://gist.github.com/sandeshbhusal/c8fa09546ffc076e5103456dd4e3742d | |
| package main | |
| import ( | |
| "flag" |
| package main | |
| import ( | |
| "bufio" | |
| "bytes" | |
| "encoding/binary" | |
| "flag" | |
| "fmt" | |
| "net" | |
| "os" |
| // +build linux | |
| package main | |
| import ( | |
| "fmt" | |
| "net" | |
| "os" | |
| "syscall" |
| package main | |
| // Simple, single-threaded server using system calls instead of the net library. | |
| // | |
| // Omitted features from the go net package: | |
| // | |
| // - TLS | |
| // - Most error checking | |
| // - Only supports bodies that close, no persistent or chunked connections | |
| // - Redirects |
| 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" |