gotamer

Crypt

This will not pass Bank or Spy cryptographic requirements in todays world. I do not make claims about its security, please see the license file for details. Advise: Please evaluate your needs and take additional measures to fit your needs. For example in my case I use multiple keys for each instance, and my application selects the keys randomly. It is rune aware, it supports the full line of Go UTF-8 characters

Encode/Decode between struct and byte slice

sbs stands for Struct to Byte Slice and back to Struct Internals: sbs encodes your struct first to a Gob, then it convers it to a byte slice; it reverses the process for decoding. Example type Foo struct { A int B string } p := &Foo{111,"A string"} byteslice, err := sbs.Enc(p) ... foo := new(Foo) structobject, err := sbs.Dec(foo, byteslice) ... Code is available at https://bitbucket.org/gotamer/sbs

GoWatch

GoTamer gowatch is a fork of bitbucket.org/jzs/buildwatch with some enhancements. gowatch -test will run go test on the folder gowatch -build will run go build on the folder gowatch -run [program_name] will run go build and then it will execute [program_name] If a file changes while running lets say gowatch -run [program_name] it will kill [program_name], run gowatch -build on the folder, and then restart [program_name] Links Website Pkg Documentationn Repository

Ping

There are two ways to ping go internal ping sys ping The go internal ping works only as root, therefor a sys ping is also provided until I can figure out how to fix this problem. Website Code is available at https://bitbucket.org/gotamer

Smtp

Now gotamer/mail also implements the io.Writer interface. Example: package main import ( "fmt" "bitbucket.org/gotamer/mail" ) func main() { s := new(mail.Smtp) s.SetHostname("smtp.gmail.com") s.SetHostport(587) s.SetFromName("GoTamer") s.SetFromAddr("xxxx@gmail.com") s.SetPassword("*********") s.AddToAddr("to@example.com") s.SetSubject("GoTamer test smtp mail") s.SetBody("The Writer below should replace this default line") if _, err := fmt.Fprintf(s, "Hello, smtp mail writer\n"); err != nil { fmt.Println(err) } } As an alternative to AddToAddr() there is SetToAddrs(). With SetToAddrs() you can set one or more recipients as a comma separated list.

Your Everyday Go Tools

Generates a random number between min and max func IRand(min, max int) int Generates a random strings between min and max func SRand(min, max int, readable bool) string Reverses the string func Reverse(s string) strings Shuffles the string func Shuffle(s string) string Links Pkg Documantation Repository

Encode/Decode Golang data to Gob files

Golang has a package called Gob to encode and decode values in to go specific binary format for transmiting as streams or for saving to file. Below are two functions, Load and Save to encode/decode go values including struct’s in to files. package main import ( "encoding/gob" "fmt" "os" "runtime" ) const file = "/tmp/test.gob" type User struct { Name, Pass string } func main(){ var datato = &User{"Donald","DuckPass"} var datafrom = new(User) err := Save(file, datato) Check(err) err = Load(file, datafrom) Check(err) fmt.