Golang

Follow my Golang journey through this link.


File Access and Create Time

Little update (like 5 years later). Just tried this on Windows and no it doesn’t work. I get following error: `undefined: syscall.Stat_t` This works on Linux. Haven’t tried on any other platform, please report if you do. https://play.golang.org/p/vJFZ1o_qIp package main import( "fmt" "os" "time" "syscall" ) type FileTime struct { MTime time.Time CTime time.Time ATime time.Time } const FILE = "/opt/go/LICENSE" func main(){ file, err := FTime(FILE) if err == nil { fmt.

A Gopher named Gophy

If you are just starting out with Go, head over to the Go Playground and concentrate on figuring out how my little Go Story works. It’s about a Gopher, named Gophy who joint the Gophers but lost his identity in the process. Once you get how he gets his identity back you’ll be golden. Here is the code: package main import "fmt" type I interface{} var gophers map[uint]I = make(map[uint]I) type gopher struct { Name string } func main() { g := AddToGophers("Goghy") fmt.

Cases

Provides conversion and case manipulation, such as upper case word, camel case, dash, underscore etc. I created this for a Wiki I been working on as a learning experience for Go Pkg Documantation Repository

Cfg

Features: You can define your config items in your application as a struct. You can save a json template of your struct You can save runtime modifications to the config Docs: import "bitbucket.org/gotamer/cfg" func Load(filename string, o interface{}) (err error) Load gets your config from the json file, and fills your struct with the option func Save(filename string, o interface{}) (err error) Save will save your struct to the given filename, this is a good way to create a json template

Conv

Don’t use this!!! Don’t even try to learn from it, this was one of my first Go codes, most of it is just plain wrong! Converts from string to byte string to int string to uint int to string uint to string byte to string byte to int []byte to string string to []byte

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

Go Snippets

time Unix time to Date d := time.Unix(1348102780, 0).Format(time.UnixDate) GoPlay unicode/utf8 RuneCount rc := utf8.RuneCount([]byte("dsjkdshdjsdh..Ü..js")) GoPlay encoding/base64 Encode value = base64.StdEncoding.EncodeToString([]byte("Hello World")) Decode hw, err := base64.StdEncoding.DecodeString(value) GoPlay

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

jgdb

About the implementation: This project is in alha state! Object Types Tuple (In Memory Database) Beta List (Single file persistent database) Beta Object (Multi file persistent database) Alpha Cache (Cache for Tuple) Not yet implemented Backends Json Glob Not yet implemented The major distinction between List and Object is that one, the List type uses a single file as backend with each record placed in one line.