🇧🇷 Read this documentation in Portuguese
If you're tired of manual builds, complicated deploys, confusing versioning, and want a stylish, easy-to-extend, production-ready CLI, GoForge is for you!
Create a new file at cmd/cli/hello.go:
package cli
import (
"fmt"
"github.com/spf13/cobra"
)
var HelloCmd = &cobra.Command{
Use: "hello",
Short: "Custom command example",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Hello, world! Custom command working!")
},
}In wrpr.go, register the command:
// ...existing code...
rootCmd.AddCommand(cli.HelloCmd)
// ...existing code...import gl "github.com/rafa-mori/goforge/logger"
func exampleWithContext() {
gl.Log("warn", "Warning! Something might be wrong.")
gl.Log("debug", map[string]interface{}{
"user": "rafael",
"action": "login",
"success": true,
})
}import "github.com/rafa-mori/goforge"
func main() {
var myModule goforge.GoForge = &MyModule{}
if myModule.Active() {
_ = myModule.Execute()
}
}
// Implement the GoForge interface in your moduleGoForge is a template/base project for any modern Go module. It delivers:
- Multi-platform build (Linux, macOS, Windows) with no code changes
- Automatic UPX compression for optimized binaries
- Automatic publishing to GitHub Releases
- Centralized configuration via
info/manifest.jsonwith embedded access - Organized build artifacts in dedicated
bin/directory - Automatic checksum to ensure binary integrity
- Custom, stylish CLI (cobra), ready to extend
- Flexible architecture: use as a library or executable
- Automatic versioning: CI/CD fills and embeds the version in the binary
- Structured logger: contextual, colored logging with levels and line tracing
All this without changing your module's code. The workflow is modular, dynamic, and adapts to any environment!
./
├── .github/workflows/ # CI/CD workflows (release, checksum)
├── goforge.go # GoForge interface for library use
├── cmd/ # CLI entrypoint and commands
│ ├── cli/ # Utilities and example commands
│ ├── main.go # CLI application main
│ ├── usage.go # Custom usage template
│ └── wrpr.go # Command structure and registration
├── go.mod # Go dependencies
├── info/ # Application metadata and manifest
│ ├── manifest.json # Central application configuration
│ └── application.go # Go interface for manifest access
├── logger/ # Global structured logger
│ └── logger.go # Contextual, colored logger
├── Makefile # Entrypoint for build, test, lint, etc.
├── bin/ # Build artifacts directory (created during build)
├── support/ # Helper scripts for build/install
└── version/ # Automatic versioning
├── CLI_VERSION # Filled by CI/CD (deprecated)
└── semantic.go # Semantic versioning utilities
- No headaches with builds and deploys
- Production-ready CLI that's easy to customize
- Powerful logger: debug, info, warn, error, success, all with context
- Automatic versioning: never forget to update your version again
- Easy to extend: add commands, use as a library, plug into other projects
make installmake buildThe binary will be generated in the bin/ directory as bin/goforge.
./bin/goforge --helpCreate files in cmd/cli/ and register them in wrpr.go.
import gl "github.com/rafa-mori/goforge/logger"
gl.Log("info", "Informative message")
gl.Log("error", "Something went wrong!")The logger automatically includes context (line, file, function)!
The info/manifest.json file contains the application version and metadata. The version system integrates with GitHub to check for updates. The goforge version command shows the current and latest version from GitHub.
GoForge features a sophisticated distribution system with centralized configuration through info/manifest.json. For detailed information about the build process, versioning, and CI/CD integration, see:
📋 Distribution & Versioning Documentation
This covers:
- Manifest-driven architecture
- Multi-platform build process
- Binary optimization and organization
- CI/CD automation
- Version management system
Pull requests, issues, and suggestions are very welcome. Let's evolve together!
MIT. See the LICENSE file.
Rafael Mori — @rafa-mori
Made with 💙 for the Go community. Let's automate everything!
