1
0

removing useless buffer, changing token type to int constants

This commit is contained in:
2021-03-04 17:48:40 +01:00
parent 13a990bb4a
commit caea5f7c25
2 changed files with 18 additions and 14 deletions

View File

@ -4,28 +4,34 @@ import (
"fmt"
)
const (
URL = iota
TAG
DESCRIPTION
)
type Token struct {
Type string
Type int
Value string
}
func (t Token) String() string {
return fmt.Sprintf("%s : '%s'", t.Type, t.Value)
return fmt.Sprintf("%v : '%s'", t.Type, t.Value)
}
func Parse(t []Token) Feed {
var f Feed
for i := range t {
token := t[i]
if token.Type == "URL" {
if token.Type == URL {
f.URL = token.Value
}
if token.Type == "DESC" {
if token.Type == DESCRIPTION {
f.Description = token.Value
}
if token.Type == "TAG" {
if token.Type == TAG {
f.Tags = append(f.Tags, token.Value)
}
}