Go Ship! banner

Go Ship!

4 devlogs
16h 20m 37s

The site for the Go Ship! YSWS draft, written in 100% Golang (excluding html and css). Features a HCA RSVP button, FAQ, guides, and an AI idea generator, code runner using go.dev/play, and some other smaller stuff.

This project uses AI

Claude Code used for code assist/debugging, copilot tab completion.

Demo Repository

Loading README...

BnaJns

Shipped this project!

Finished the whole v1 site for the YSWS draft Go Ship!, including a bunch of cool stuff such as:

  • RSVP via Hack Club Auth (instead of a fillout form)
  • markdown rendered guides
  • ai.hackclub.com project idea generator (spins 3 categories, POSTs to AI, returns go beginner project idea)
  • code runner with examples via go.dev/play API
  • and some smaller stuff like the art/FAQ/prizes/text/etc

Is writing the site as fast as using a framework like next.js, astro, or even gin-gonic to help with handlers? No. Is the executable a whole 20mb and really fast? Hell yeah.

BnaJns

Added a golang code playground with examples cause why not, courtesy of go.dev/play servers, very epic

  • CodeMirror for the Go code editor/display via their cdn links
  • go.dev/play APIs for formatting + running code in a sandbox, really simple to use
  • Wrote 3 basic example scripts, a hello world with time, the infinite monkey theorem thingy using gocurrency and channels, and also copied the base64 image displayer example from go.dev/play, just added the support to my html and changed the logo to be the goship logo ofc
  • Backend is basically a really simple proxy, formats raw code text into x-www-form-urlencoded and into the expected struct, sends it to the API which handles the formatting and building, sends back the json response to the client.
  • //go:build ignore lines in the public/scripts/ scripts so it doesnt break the actual website build, and then the client JS strips it out so it doesnt stop the script from running in the playground.
  • Also added ratelimits to format/run to prevent abuse/spam
  • Edit: Also emailed the Golang public mailing list as per the service requirements, https://groups.google.com/g/golang-dev

i didnt know you could add emojis this is cool

gopher gopher gopher

Changelog

Attachment
0
BnaJns

Pretty much done atp adding guides was easier than i expected it to be

  • Added three very awesome guides, the Go setup guide, the hackatime setup (which just basically links to the hackatime website quick start), and a hello world tutorial.
  • Added a /guides handler, using yuin/goldmark to render the markdown in the template. On /guides?file.md request, checks if file exists, if not respond 404, and ofc other cases like no query param or whatever, if file does exist, it reads the markdown, renders it using goldmark, throws into template, boom.
  • Basic guides/index.html template with simple styling
  • Made the readme awesome, aka changed it from 3 lines to like 50 lines

Go is awesome

Changelog

Attachment
Attachment
0
BnaJns

AI generated ideas working after wayy too much time, woo

  • Added an /generatemeaidea endpoint with POST and GET available, GET returns allowed slot tiles/categories, and POST generates and AI idea via ai.hackclub.com with the generated slot ideas, also double checking to make sure the categories are in the allowed list, and also with a 10 req/hour ratelimit.
  • Frontend is simple, you have a slot machine, “spin” button, you click it, it randomly chooses 3 categories, sends the request to the endpoint, gets response back, puts that on display. If ratelimited, or error, it throws a message saying ratelimited/error happened.
  • I tried to make a pullable lever, and make a the slots have a spin animation, but I gave up after a few minutes as I couldn’t be really bothered

Very awesomesauce

Changelog

Attachment
0
BnaJns

devlogging this only now cause I never planned to submit this to flavortown
Alright so ~11 hours, that’s a lot of time, what did I achieve in that timeline? Imma break it down to the best of my memory:

  1. Initial stuff, setting everything up, go mod init yadayada. Why go with Go (no pun intended)? Because it’s a very cool and easy to learn language, I barely have experience btw, yet writing stuff is simple, also has a powerful standard library, and it’s basically if Python was a good language. And if I was making a golang YSWS, and didn’t write the site in golang, that’d be a missed opportunity. And why the name “Go Ship!”? Google the card game “Go Fish”. Also, was originally going to use a makefile, but on windows it was a pain, so I discovered taskfile instead, which is also written in Go, and it’s way more awesomesauce than makefile imo.

  2. Started building the HTML/CSS and stuff, I’m way too used to react and tailwind so this was a bit slow for me, I could’ve used the tailwind play CDN , but, the IDE wouldn’t autosuggest the classes and stuff then, so I just decided to stick to good old plain HTML+CSS+JS, and it wasn’t that bad. And then I also worked on the RSVP functionality. Fillout? LAME. Using hack club identity? Awesomesauce. Sqlite, Identity, boom, you got a good clean minimal RSVP database, and I can also expand it to support logins as well in the future, technically it already does that with cookies, but it probably needs to be more secure and advanced. No SQLi or anything in there, yet, but still. Basically how the auth/rsvp works is the RSVP button links to hack club auth, user authenticates, gets sent back to callback link, Go grabs the params from the callback request, sends tokens and stuff to HCA, HCA sends response back with more tokens, Go verifies the legitimacy with public keys and JWT to make sure the response is legit, if everything matches, fetch user data from userinfo endpoint with the given user token, save info to the DB and create a session, give the cookie to the user (so they can see they’ve already RSVPed on their browser), 5 big booms.

  3. Was basically finished at this point, according to commits, added a few waves to the HTML, also wrote a test cause tests are cool when the orange dot turns to green dot instead of red dot in github, messing around with github actions to setup stuff properly from builds to tests, added a .env.example along with a port option (cause 3000 was already taken on my homelab), added responsiveness to mobile, opengraph for cool embeds on slack/discord, github commit id to the footer because it’s cool, not very useful but cool. Finished stuff up with a potential prizes carousel, and a /stats endpoint which just shows the RSVP count and the binary uptime, the /stats is not used anywhere, yet, but still.

  4. Getting up hosted on goship.dino.icu was a bit complicated, since I could’ve just hosted it on goship.bnajns.dev, used CF tunnels called it a day but I wanted to make sure it was on dino.icu, which doesn’t really work with cross-account tunnels afaik, so what I did instead was spin up a free azure VM, install FRP on that and my homelab, did configuring, and used that as a proxy instead, and it works fine.

And that’s pretty much it, I also had the idea to use ai.hackclub.com to make a project idea generator since I saw that idea being used in a few other places, so I’ll add that soon, and also guides, I’ll need to write those as well.

Attachment
Attachment
0