Skip to content

Commit 95a7c70

Browse files
committed
blogs
1 parent 4c52afe commit 95a7c70

File tree

4 files changed

+66
-3
lines changed

4 files changed

+66
-3
lines changed

public/data/shownPosts.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
[
2+
{
3+
"slug": "do-i-need-to-create-a-lib-for-that",
4+
"title": "Do I Need to Create a Lib For That?",
5+
"date": "2025-10-16",
6+
"updated": "2025-10-16",
7+
"description": "a journey to create my first golang package",
8+
"tags": ["go", "lib", "pkg.go.dev"]
9+
},
210
{
311
"slug": "warning-post",
412
"title": "My Second Post",
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Do I Need to Create a Lib For That?
2+
3+
## My Journey into Go Libraries
4+
5+
Creating my first Go library, [go-tournament-brackets](https://github.com/fezcode/go-tournament-brackets), has been a, _experience_...
6+
It's a project that allowed me to dive deep into Go's capabilities for building reusable and efficient code.
7+
The process of designing the data structures, handling edge cases like automatic bye calculations,
8+
and then building an interactive command-line interface on top of it was both challenging and immensely satisfying.
9+
There's a unique sense of accomplishment in seeing your code not just work, but also be easily consumable by others.
10+
11+
## About `go-tournament-brackets`
12+
13+
`go-tournament-brackets` is a versatile Go library designed for generating and managing single-elimination tournament brackets. It offers two primary components:
14+
15+
* **A Robust Go Library:** This provides a set of data models and functions that can be integrated into any Go application.
16+
It intelligently handles tournament logic, including the correct calculation of rounds, match-ups, and automatic byes for varying numbers of participants.
17+
* **An Interactive Command-Line Interface (CLI):** Built on top of the library, this CLI allows users to run a tournament from start to finish.
18+
You can input participant names, visualize the bracket in ASCII art, and interactively determine match winners until a champion is crowned.
19+
20+
This library aims to simplify the process of setting up and managing tournaments, whether you're integrating it into a larger application or running a quick tournament from your terminal.
21+
22+
## Ok, but why?
23+
24+
The inspiration for `go-tournament-brackets` struck during a casual phone call with a friend. I was unwinding, listening to [Morcheeba's "Easier Said than Done,"](https://www.youtube.com/watch?v=27lPAUdE1ys)
25+
when he posed a fun challenge: rank our favorite rappers. His idea was to create a bracket, share it, and play through it together. Simple enough, right?
26+
27+
Not quite. As he started looking for online bracket makers, we quickly hit a wall. Most platforms demanded sign-ups,
28+
locked away certain tournament types behind paywalls, and generally overcomplicated what should have been a straightforward,
29+
enjoyable activity. For something so simple, the hoops we had to jump through felt entirely unnecessary.
30+
That's when the idea sparked: why not build my own? A bracket maker that was free, flexible, and didn't force you into a convoluted user experience.
31+
And so, the seed for `go-tournament-brackets` was planted.
32+
33+
## How did I do that?
34+
35+
The journey from idea to a working library began with a deep dive into the mechanics of tournament brackets.
36+
I found myself poring over Wikipedia articles, unraveling the intricacies of single-elimination formats, byes, and seeding.
37+
Once I had a solid grasp of the theoretical underpinnings, I turned to my trusty collaborator, Gemini 2.5-Pro.
38+
39+
My first request to Gemini was simple: "Generate the necessary Go files for a tournament bracket library."
40+
It quickly scaffolded the basic project structure, providing the initial Go files. From there, I started defining the core data structures,
41+
translating the concepts from my research into Go structs. The `models.go` file, which you can see [here](https://raw.githubusercontent.com/fezcode/go-tournament-brackets/refs/heads/main/models.go), was born out of this phase.
42+
43+
```go
44+
// Tournament is the root object that contains all data for a tournament event.
45+
type Tournament struct {
46+
Name string
47+
Rounds []Round
48+
TournamentType TournamentType
49+
Options *Options
50+
}
51+
```
52+
53+
With the foundational structs in place, Gemini and I embarked on implementing the core logic.
54+
This was where the real challenge and fun began. Handling the "bye" mechanism – __ensuring that teams or competitors who automatically advance in the first round are correctly placed__ – proved to be particularly tricky.
55+
It's not as straightforward as it might seem, but with Gemini's assistance, we iterated through various approaches, and it did its best to help navigate those complexities. It was a true collaborative effort, pushing both my understanding and Gemini's capabilities to deliver a robust solution.

src/pages/BlogPostPage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import React, { useState, useEffect, useRef } from 'react';
22
import { useParams, Link } from 'react-router-dom';
33
import ReactMarkdown from 'react-markdown';
44
import PostMetadata from '../components/PostMetadata';
5-
import { ArrowLeftIcon } from '@phosphor-icons/react';
5+
import { ArrowLeftIcon, ArrowSquareOutIcon } from '@phosphor-icons/react';
66

77
const LinkRenderer = ({ href, children }) => {
88
const isExternal = href.startsWith('http') || href.startsWith('https');
99
return (
1010
<a href={href} className="text-primary-400 hover:text-primary-600 transition-colors inline-flex items-center gap-1" target={isExternal ? "_blank" : undefined} rel={isExternal ? "noopener noreferrer" : undefined}>
11-
{children} {isExternal && <ArrowLeftIcon className="text-xs" />}
11+
{children} {isExternal && <ArrowSquareOutIcon className="text-xs" />}
1212
</a>
1313
);
1414
};

tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ module.exports = {
7878
},
7979

8080
li: {
81-
lineHeight: '1.0',
81+
lineHeight: '1.5',
8282
},
8383
},
8484
},

0 commit comments

Comments
 (0)