Skip to content

Instantly share code, notes, and snippets.

@pat36
Created July 15, 2017 13:18
Show Gist options
  • Save pat36/368aa2c51ed765bc2be8a14e07df384e to your computer and use it in GitHub Desktop.
Save pat36/368aa2c51ed765bc2be8a14e07df384e to your computer and use it in GitHub Desktop.
null created by anonymous - https://repl.it/JJTe/0
package main
import "fmt"
type Board struct {
ID string
OwnerID string
ShortName string
Anonymize bool // No namefagging
}
type Owner struct {
ID string
Name string
Password []byte
Owns []Board
}
// There are no Users only posts
type Post struct {
Poster string // Anon/Namefagging
Avatar string // Avatarfagging
Message string
Anonymize bool // Always return Anonymous; override or use board default.
}
func NewPost(Name, Avatar, Message string, Anonymize bool) Post {
n := Post{Name, Avatar, Message, Anonymize}
return n
}
func (bp *BoardPost) GetName() string {
if bp.Board.Anonymize || bp.Post.Anonymize {
return "Anonymous"
} else {
return bp.Poster
}
}
type BoardPost struct {
Board
Post
}
func NewBoardPost(board Board, post Post) BoardPost {
n := BoardPost{Board: board, Post: post}
// save to database here
return n
}
func (bp *BoardPost) String() string {
return fmt.Sprintf("[%s]\t %s: %s", bp.ShortName, bp.GetName(), bp.Message)
}
func main() {
o := Owner{"uu", "meep", []byte("sexytime"), nil}
b := Board{"fiddlemedotter", o.ID, "test board", true}
p := NewPost("bearpolice", "bear.gif", "No Poo in forest", false)
x := NewBoardPost(b, p)
fmt.Println(x.String())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment