Follow the story of the Little Blue Gopher with this Golang Web Application.
Table of Contents
The Golang Create Your Own Adventure web application reads in a story provided by a JSON file in the following format:
{
"story-arc": {
"title": "A title for that story arc. Think of it like a chapter title.",
"story": [
"A series of paragraphs, each represented as a string in a slice.",
"This is a new paragraph in this particular story arc."
],
"options": [
{
"text": "the text to render for this option. eg 'venture down the dark passage'",
"arc": "the name of the story arc to navigate to. This will match the story-arc key at the very root of the JSON document"
}
]
}
}
Each story arc will have a unique key that represents the name of that particular arc, and each adventure will have a story arc with the key "intro" that represents the first story arc of the adventure. Options will be empty if it is the end of that particular story arc. Otherwise, options will have one or more JSON objects that represent an "option" that the reader has at the end of a story arc.
The story is made available to the user using Go templates and http routes. If a user visits the root route (i.e., http://localhost:8080/), the user will be shown the intro story arc.
The story JSON file defaults to "adventure.json", but the user can choose a different file by using the "-filename" flag followed by the name of the JSON file.
- Golang: https://go.dev/doc/install
- Clone the repo
git clone https://github.com/cjsidler/go-cyoa.git
- Build an executable
go build -o "go-cyoa.exe" main.go
- Run the executable.
.\go-cyoa.exe -filename "mystory.json"
Contact me via email, LinkedIn, or GitHub: