Go R1 Day 65
progress🔗
- Built mage tasks for go formatting and linting.
Using this approach, you can now drop a magefile.go
file into a project and set the following:
// +build mage
package main
import (
"github.com/magefile/mage/mg"
"github.com/pterm/pterm"
// mage:import
"github.com/sheldonhull/magetools/gotools"
)
Calling this can be done directly now as part of a startup task.
// Init runs multiple tasks to initialize all the requirements for running a project for a new contributor.
func Init() error {
fancy.IntroScreen(ci.IsCI())
pterm.Success.Println("running Init()...")
mg.Deps(Clean, createDirectories)
if err := (gotools.Golang{}.Init()); err != nil { // <----- From another package.
return err
}
return nil
}
Additionally, handled some Windows executable path issues by making sure to wrap up the path resolution.
// if windows detected, add the exe to the binary path
var extension string
if runtime.GOOS == "windows" {
extension = ".exe"
}
toolPath := filepath.Join("_tools", item+extension)
Links🔗
- feat(gotools): ✨ add gotools for running go specific actions · sheldonhull/magetools@ef97514 · GitHub
- refactor(gotools): 🚚 add namespace for Golang and update lint ci to d… · sheldonhull/magetools@51a9c3b · GitHub
- feat(gotools): 🎉 add go formatting and linting helpers · sheldonhull/magetools@541c2fc · GitHub
- refactor(gotools): 🔨 windows support for executables · sheldonhull/magetools@d70712e · GitHub