more tests for good boy points, split entities into files
This commit is contained in:
34
token.go
Normal file
34
token.go
Normal file
@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
Type string
|
||||
Value string
|
||||
}
|
||||
|
||||
func (t Token) String() string {
|
||||
return fmt.Sprintf("%s : '%s'", t.Type, t.Value)
|
||||
}
|
||||
|
||||
func Parse(t []Token) Feed {
|
||||
var f Feed
|
||||
for i := range t {
|
||||
token := t[i]
|
||||
if token.Type == "URL" {
|
||||
f.URL = token.Value
|
||||
}
|
||||
|
||||
if token.Type == "DESC" {
|
||||
f.Description = token.Value
|
||||
}
|
||||
|
||||
if token.Type == "TAG" {
|
||||
f.Tags = append(f.Tags, token.Value)
|
||||
}
|
||||
}
|
||||
|
||||
return f
|
||||
}
|
||||
Reference in New Issue
Block a user