add URL to Page struct
This commit is contained in:
parent
dd3b4159ec
commit
06b03d7480
14
main.go
14
main.go
|
@ -15,6 +15,7 @@ type hlink struct {
|
|||
type Page struct {
|
||||
Body string
|
||||
Links []hlink
|
||||
URL string
|
||||
}
|
||||
|
||||
type Game struct {
|
||||
|
@ -80,15 +81,18 @@ func fparse(fname string) Game{
|
|||
case len(line) == 0:
|
||||
pcount++
|
||||
case string(line[0]) == ":":
|
||||
game.Pages = append(game.Pages, Page{Body:cutFirstWord(line)})
|
||||
fmt.Println(cutFirstWord(line))
|
||||
sline := strings.Split(line, " ")
|
||||
url := sline[0][1:] + ".html"
|
||||
fmt.Println(url)
|
||||
body := strings.Join(sline[1:]," ")
|
||||
fmt.Println(body)
|
||||
game.Pages = append(game.Pages, Page{Body:body,
|
||||
URL: url})
|
||||
//game.Pages = append(game.Pages, Page{Body:cutFirstWord(line)})
|
||||
case string(line[0]) == "-":
|
||||
newLink := line2link(line)
|
||||
game.Pages[pcount].Links = append(game.Pages[pcount].Links, newLink)
|
||||
}
|
||||
|
||||
//fmt.Println(firstchar)
|
||||
//game.Pages = append(game.Pages()
|
||||
}
|
||||
return game
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue