A lightweight Go vanity import path server that allows you to use custom domain names for your Go packages.
Go vanity import paths allow you to use your own domain for Go package imports instead of directly referencing the hosting service. For example:
import "go.gllm.dev/mypackage"Instead of:
import "github.com/gllm-dev/mypackage"- π Simple and lightweight - Minimal dependencies and fast startup
- π³ Docker-ready - Multi-stage Dockerfile for tiny production images
- π§ Easy configuration - Just two environment variables
- π¦ Works with any Git host - GitHub, GitLab, Bitbucket, or self-hosted
- π― Focused - Does one thing and does it well
When someone runs go get your.domain/package, the Go tool makes an HTTP request to your vanity server. The server responds with HTML containing special meta tags that tell Go where to find the actual repository:
<meta name="go-import" content="go.gllm.dev/mypackage git https://github.com/gllm-dev/mypackage">
<meta name="go-source" content="go.gllm.dev/mypackage https://github.com/gllm-dev/mypackage https://github.com/gllm-dev/mypackage/tree/main{/dir} https://github.com/gllm-dev/mypackage/blob/main{/dir}/{file}#L{line}">docker run -d \
-p 8080:8080 \
-e VANITY_DOMAIN=go.gllm.dev \
-e VANITY_REPOSITORY=https://github.com/gllm-dev \
vanity-go:latestversion: '3.8'
services:
vanity-go:
image: ghcr.io/gllm-dev/vanity-go:latest
ports:
- "8080:8080"
environment:
- VANITY_DOMAIN=go.gllm.dev
- VANITY_REPOSITORY=https://github.com/gllm-dev
restart: unless-stopped# Clone the repository
git clone https://github.com/gllm-dev/vanity-go.git
cd vanity-go
# Build the binary
go build -o vanity-go cmd/main.go
# Run with environment variables
VANITY_DOMAIN=go.gllm.dev VANITY_REPOSITORY=https://github.com/gllm-dev ./vanity-goThe server requires two environment variables:
| Variable | Description | Example |
|---|---|---|
VANITY_DOMAIN |
Your vanity domain | go.gllm.dev |
VANITY_REPOSITORY |
Base repository URL | https://github.com/gllm-dev |
PORT |
Server port (optional) | 8080 (default) |
apiVersion: apps/v1
kind: Deployment
metadata:
name: vanity-go
spec:
replicas: 2
selector:
matchLabels:
app: vanity-go
template:
metadata:
labels:
app: vanity-go
spec:
containers:
- name: vanity-go
image: ghcr.io/gllm-dev/vanity-go:latest
ports:
- containerPort: 8080
env:
- name: VANITY_DOMAIN
value: "go.gllm.dev"
- name: VANITY_REPOSITORY
value: "https://github.com/gllm-dev"
---
apiVersion: v1
kind: Service
metadata:
name: vanity-go
spec:
selector:
app: vanity-go
ports:
- port: 80
targetPort: 8080If you're using Nginx as a reverse proxy:
server {
listen 80;
server_name go.gllm.dev;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Once deployed, users can import your packages using your custom domain:
# Install a package
go get go.gllm.dev/mypackage
# Import in Go code
import "go.gllm.dev/mypackage"The server will automatically handle any package path under your domain:
go.gllm.dev/pkg1βhttps://github.com/gllm-dev/pkg1go.gllm.dev/pkg2βhttps://github.com/gllm-dev/pkg2go.gllm.dev/tools/cliβhttps://github.com/gllm-dev/tools
- Go 1.21 or later
- Docker (optional, for containerized development)
go test ./...docker build -t vanity-go:latest .We welcome contributions! Please see our Contributing Guidelines for details.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by the simplicity of Go's vanity import path system
- Built with love for the Go community
- π Report bugs
- π‘ Request features
- π Read the docs
Made with β€οΈ by the Go community