From 06b03d7480eb5dcb74bd990b9d2124251dada155 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 4 Jan 2020 16:31:46 +0100 Subject: [PATCH] add URL to Page struct --- main.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index fe52fbe..192c376 100644 --- a/main.go +++ b/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 }