package main import ( "html/template" "sync" ) type Post struct { BlogTitle string Lang string Id string Title string Author string Date string HTML template.HTML Text string } type Blog struct { Title string Lang string Posts []Post mutex sync.Mutex } func (b *Blog) GetPost(Id string) (Post, bool) { var ret Post b.mutex.Lock() defer b.mutex.Unlock() for _, p := range b.Posts { if p.Id == Id { ret = p ret.BlogTitle = b.Title ret.Lang = b.Lang return ret, true } } return ret, false }