I want to build a parser but have some problems understanding how to do this.
Sample string I would like to parse
{key1 = value1 | key2 = {key3 = val
Writing a parser is a complicated topic that is too big to cover in a single answer.
Rob Pike gave an excellent talk that walks through writing a lexer (which is a half of the parser) in Go: http://www.youtube.com/watch?v=HxaD_trXwRE
You should also look at e.g. parser code in Go standard library for an example on how to do it: http://golang.org/src/pkg/go/parser/parser.go
There's also plenty resources on parsing on the internet. They might have examples in other languages but it's just a matter of translating the syntax to Go.
I recommend reading up on recursive descent parsing (e.g. http://www.cs.binghamton.edu/~zdu/parsdemo/recintro.html) or top down parsing (e.g. http://javascript.crockford.com/tdop/tdop.html, http://effbot.org/zone/simple-top-down-parsing.htm).