Public Wiki164,796View on GitHub
Want avelino/awesome-go knowledge in your AI?

main.go

A Go-based toolchain for maintaining and publishing the awesome-go curated list. It validates the README.md for structural correctness (alphabetical ordering, no duplicates, proper formatting), checks that linked GitHub repositories are not stale/archived/inactive, and generates a static HTML website from the markdown source with navigation, categorization, and SEO support.

Key Features

  • README structural validation
  • Stale repository detection
  • Static site generation pipeline
  • Markdown to HTML conversion
  • URL slug generation

Entry Points

Start here when working with this codebase

Main Entry - Site Generator
main.go

Orchestrates the complete static site generation pipeline: reads awesome-go README.md, parses markdown, generates multi-page HTML website with navigation, categorization, and SEO support

Start here when modifying the site generation pipeline, adding new output formats, changing how categories are processed, or altering the overall build flow

Validation Tests
main_test.go

Automated quality assurance for the awesome-go README.md: validates structure, prevents duplicates, enforces alphabetical ordering, and verifies rendering

Start here when adding new validation rules for README entries, changing ordering requirements, or adding new structural checks for the awesome-go list

Stale Repository Detection
stale_repositories_test.go

Detects and reports stale, archived, moved, or inactive GitHub repositories by querying the GitHub API during periodic test execution

Start here when modifying staleness criteria (e.g., changing the inactivity threshold), adding new repository health checks, or integrating additional source control platforms beyond GitHub

Markdown Converter
pkg/markdown/convert.go

Converts markdown content to HTML with custom heading ID generation for the awesome-go list entries

Start here when changing how markdown is rendered to HTML, modifying heading anchor generation, or adding support for new markdown extensions

Slug Generator
pkg/slug/generator.go

Generates URL-friendly slugs from category and project names for use in page URLs and anchor links

Start here when changing URL slug generation rules, handling new special characters, or modifying how category/project names map to URL paths

How to Make Changes

Common modification patterns for this codebase

Add a new validation rule for README entries

1
main_test.go

Add a new test function following the existing Test* naming convention. Study how existing tests like those checking alphabetical ordering or duplicate detection parse the README.md content line by line

Pattern: See how existing test functions in main_test.go use Go's testing.T, read README.md content, iterate over lines, and call t.Errorf for violations. Each validation rule is its own Test* function

2
main_test.go

If your validation needs helper functions, add them as unexported functions in the same file, following the pattern of existing helper functions that parse markdown lines or extract link data

Pattern: Look at existing helper functions in main_test.go that extract URLs, parse list items, or check formatting — add your helper in the same style with clear parameter names and return values

Conventions to follow:

Each validation rule is a separate Test* function in main_test.goTests read and parse the README.md file directlyUse t.Errorf with descriptive messages that include the line number and the offending contentHelper functions are unexported (lowercase) and colocated in main_test.goTests should be deterministic and not depend on external network calls (unlike stale_repositories_test.go)

Add a new repository health check (e.g., check for license, minimum stars)

1
stale_repositories_test.go

Study the existing stale repository detection logic to understand how it extracts GitHub URLs from README.md and queries the GitHub API. Add your new health check as a new Test* function or extend the existing staleness check

Pattern: Follow the pattern in stale_repositories_test.go where GitHub URLs are extracted from the README, the GitHub API is called for each repository, and results are reported via t.Errorf with the repo URL and reason for failure

2
stale_repositories_test.go

If your check requires new GitHub API fields (e.g., license info, stargazers_count), extend the API response struct or add a new API call following the existing HTTP request pattern with proper authentication headers

Pattern: See how stale_repositories_test.go constructs GitHub API requests with authorization headers and parses JSON responses into Go structs. Add new fields to the existing response struct or create a new one

Conventions to follow:

GitHub API token is read from environment variables for authenticationTests in this file are expected to make network calls and may be run on a schedule rather than every commitReport failures with t.Errorf including the full repository URL and a clear reasonHandle API rate limiting and HTTP errors gracefully with appropriate skip/retry logic

Add a new utility package (e.g., a URL validator, a badge generator)

1
pkg/slug/generator.go

Study this file as the reference pattern for creating a new utility package. Note the package declaration, exported function signatures, and how it provides a single focused utility

Pattern: pkg/slug/generator.go defines a focused package with a clear exported function. Your new package should follow the same structure: pkg/<name>/<name>.go with a clear package declaration and exported functions with Go doc comments

2
pkg/markdown/convert.go

Study this file as a second reference for a slightly more complex utility package that may have dependencies. Note how it handles custom configuration (heading ID generation)

Pattern: pkg/markdown/convert.go shows how to wrap an external library with custom behavior. If your utility wraps a third-party library, follow this pattern of providing a clean exported API that hides implementation details

3
main.go

Import and integrate your new package into the site generation pipeline. Add the import path as 'github.com/<org>/<repo>/pkg/<yourpackage>' and call your exported functions at the appropriate stage of the pipeline

Pattern: See how main.go imports and uses pkg/markdown and pkg/slug — import your new package the same way and call it at the relevant pipeline stage

Conventions to follow:

Each package under pkg/ has a single focused responsibilityPackage names are short, lowercase, and descriptive (e.g., 'slug', 'markdown')Exported functions have Go doc commentsThe package directory name matches the package declarationImport paths follow Go module conventions: full module path + /pkg/<name>

Modify the markdown-to-HTML conversion (e.g., add syntax highlighting, custom link handling)

1
pkg/markdown/convert.go

Modify the conversion function to add your custom rendering behavior. If adding a new rendering feature, extend the existing conversion logic or add a new exported function

Pattern: See how convert.go already implements custom heading ID generation — follow the same approach of hooking into the markdown rendering pipeline to add your custom behavior (e.g., custom link renderer, code block handler)

2
main.go

If your change requires new configuration or a new function call, update main.go to pass the configuration or call the new function during the site generation pipeline

Pattern: See how main.go calls the markdown conversion functions from pkg/markdown — add your new function call or configuration in the same pipeline stage

3
main_test.go

If your change affects how the README renders, verify that existing rendering validation tests still pass and add new test cases if needed

Pattern: Check existing rendering-related tests in main_test.go to ensure your markdown changes don't break validation

Conventions to follow:

Markdown conversion logic lives in pkg/markdown/convert.go, not in main.goCustom rendering hooks are implemented within the convert packageChanges to rendering should not break the existing heading ID generationTest any rendering changes against the actual README.md content

Modify slug generation rules (e.g., handle new special characters, change separator)

1
pkg/slug/generator.go

Modify the slug generation function to handle the new rules. Update character replacement maps, regex patterns, or transformation logic as needed

Pattern: See the existing character handling in pkg/slug/generator.go — extend the same approach (character maps, string replacements, regex substitutions) for your new rules

2
main.go

Verify that main.go's usage of the slug package still works correctly with your changes. Check all call sites where slugs are generated for categories and project names

Pattern: Search main.go for all calls to the slug package and verify each call site produces correct output with the new rules

3
pkg/markdown/convert.go

Check if the markdown converter uses slug generation for heading IDs — if so, verify compatibility with your slug changes

Pattern: Look at how convert.go generates heading IDs and whether it uses pkg/slug or has its own logic. Ensure consistency between heading anchors and page URL slugs

Conventions to follow:

Slugs should be URL-safe: lowercase, no spaces, limited special charactersThe slug package is the single source of truth for slug generation — do not duplicate logic elsewhereChanges to slug generation affect both page URLs and navigation links, so test end-to-end

Add a new output page or section to the generated site

1
main.go

Add the new page generation logic to the site generation pipeline. Study how existing pages are generated: how categories are extracted, how HTML templates are populated, and how files are written to the output directory

Pattern: Follow the existing page generation pattern in main.go: extract data from parsed markdown → apply HTML template → write output file. Add your new page at the appropriate stage of the pipeline

2
pkg/markdown/convert.go

If your new page requires different markdown processing (e.g., extracting specific sections), add a new exported function to the markdown package

Pattern: See how convert.go provides conversion functions — add a new function that extracts or transforms the specific markdown content your new page needs

3
pkg/slug/generator.go

If your new page needs URL slugs for new types of content, verify the slug generator handles them correctly

Pattern: Test the slug generator in pkg/slug/generator.go with sample names from your new content type to ensure proper URL generation

Conventions to follow:

All site generation orchestration happens in main.goHTML templates and output writing are handled in main.go's pipelineNew pages should include proper navigation links to/from existing pagesSEO metadata (title, description) should be included in new page templatesUse pkg/slug for generating any new URL paths

Coding Conventions

Standards and patterns used in this codebase

file-organization

Standard project structure

Code is organized by feature/module
main.gomain_test.gostale_repositories_test.go