Q:

How to parse simple biggest to smallest date string in GO

Im attempting to learn go, its quite a fun language. Ive got a bunch of text files which we run imports across, the date is in the format YYYYMMDDHHmm. How do I get this to parse into an internal date format. The following doesn't work:
package main

import "fmt"
import "time"

func main() {
    t, err := time.Parse("YYYYMMDDHHmm", "201302031010")
    fmt.Println(t)

    if err != nil {
        panic(err)
    }

    fmt.Println(t)
}

http://play.golang.org/p/sl0Cti5Mqw
Neither does:
package main

import "fmt"
import "time"

func main() {
    t, err := time.Parse("201302031010", "201302031010")
    fmt.Println(t)

    if err != nil {
        panic(err)
    }

    fmt.Println(t)
}

http://play.golang.org/p/OUmfNTdlce

A:

The way time formats are specified in Go can be a little strange... What you need to do is show how the "Reference Time" (Mon Jan 2 15:04:05 -0700 MST 2006) would be displayed in your layout.
So for your format, the string you need is "200601021504".
package main

import "fmt"
import "time"

func main() {
    t, err := time.Parse("200601021504", "201302031010")
    fmt.Println(t)

    if err != nil {
        panic(err)
    }

    fmt.Println(t)
}

http://play.golang.org/p/yKVh4gOOgP
http://golang.org/pkg/time/#Parse

