• Stars
    star
    31
  • Rank 792,295 (Top 17 %)
  • Language
    Go
  • License
    MIT License
  • Created over 4 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

The forgotten go tool that executes and caches binaries included in go.mod files.

gomodrun

Build Status Release Coverage Status Go Report Card Godocs

The forgotten go tool that executes and caches binaries included in go.mod files. This makes it easy to version cli tools in your projects such as golangci-lint and ginkgo that are versioned locked to what you specify in go.mod. Binaries are cached by go version and package version.

Example

  # Run a linter
  gomodrun golangci-lint run

  # Convert a JSON object to a Go struct, properly passing in stdin.
  echo example.json | gomodrun gojson > example.go

  # Specifiy alternative root directory containing a go.mod and tools file.
  gomodrun -r ./alternative-tools-dir golangci-lint run

  # Clean your .gomodrun folder of unused binaries.
  gomodrun --tidy

Install

Source

curl -L "https://github.com/dustinblackman/gomodrun/archive/refs/heads/master.tar.gz" | tar zxvf - -C /tmp
cd /tmp/gomodrun-master/cmd/gomodrun
go install .

Usage

gomodrun works by using a tools.go (or any other name) file that sits in the root of your project that contains all the CLI dependencies you want bundled in to your go.mod. Note the // +build tools at the top of the file is required, and allows you to name your tools file anything you like.

tools.go

// +build tools

package myapp

import (
	_ "github.com/golangci/golangci-lint/cmd/golangci-lint"
	_ "github.com/onsi/ginkgo/ginkgo"
)

Run go build tools.go to add the dependencies to your go.mod. The build is expected to fail.

CLI

You can run your tools by prefixing gomodrun. A binary will be built and cached in .gomodrun in the root of your project, allowing all runs after the first to be nice and fast.

  gomodrun golangci-lint run

Programmatically

You can also use gomodrun as a library.

package main

import (
	"os"

	"github.com/dustinblackman/gomodrun"
)

func main() {
	exitCode, err := gomodrun.Run("golangci-lint", []string{"run"}, &gomodrun.Options{
		Stdin:   os.Stdin,
		Stdout:  os.Stdout,
		Stderr:  os.Stderr,
		Env:     os.Environ(),
		PkgRoot: "",
	})
}

MIT

More Repositories

1

Championify

Import recent item sets from popular aggregators like Champion.gg in to League of Legends to use within game! No hassle.
HTML
893
star
2

oatmeal

Terminal UI to chat with large language models (LLM) using different model backends, and integrations with your favourite editors!
Rust
325
star
3

streamroller

Self hosted simulcasting to Twitch, Youtube, and Facebook made easy.
Go
157
star
4

cargo-run-bin

Build, cache, and run CLI tools scoped in Cargo.toml rather than installing globally. Stop the version drifts across your team, keep it all in sync within your project!
Rust
142
star
5

phantomized

All dynamic PhantomJS ELFs in one simple tar
JavaScript
68
star
6

oatmeal.nvim

Terminal UI to chat with large language models (LLM) using different model backends, and with a plugin for Neovim!
Lua
53
star
7

speakerbot

A simple Discord music bot written in Go
Go
51
star
8

tcon

A slightly lazy shell script to run parallel commands with tmux panes through a FIFO queue.
Shell
30
star
9

languagetool-code-comments

languagetool-code-comments integrates the LanguageTool API to parse, spell check, and correct the grammar of your code comments!
Rust
29
star
10

collectd-docker-plugin

A collectd plugin that taps in the Docker Stats API
Go
25
star
11

s

A command line utility for posting status messages to social networks
Go
22
star
12

nowplaying-widget

A Spotify Now Playing widget that's accessible with anything that can render a webpage
TypeScript
16
star
13

gulp-inno

Compile Inno Setup scripts using Gulp
HTML
11
star
14

mono-signtool

Drop in replacement for Microsoft's signtool not working in Wine
Go
10
star
15

cargo-gha

Version lock, cache, and run binaries from any Github Release assets. Pull in external tools and keep the versions in sync across your team, and forget installing globally.
Rust
5
star
16

winston-electron

Slightly modified version of Winston Console to work with Electron
JavaScript
4
star
17

cordova-ListMusic

A Cordova/Phonegap/SteroidsJS plugin that lists all tracks in Android's MediaStore (default music player).
Java
3
star
18

wrappers

Small shell wrappers around language tooling to fit my personal preference
Shell
2
star
19

streamwithfriends

StreamWithFriends allows your friends webcams to appear on your stream all through a web broswer
JavaScript
2
star
20

cordova-MusicControl

Control default music player for Android from Cordova/Phonegap/Steroids.
Java
2
star
21

fetch-hls

A quick and lazy solution to proxy HLS streams to external players (Chromecast, VLC).
Go
1
star
22

cf-alias

Create Cloudflare email alias' directly from your terminal or Alfred.
Rust
1
star
23

node-cleverbot

Cleverbot library for Node
JavaScript
1
star
24

homebrew-casks

Custom casks for myself, and anyone else interested
Ruby
1
star
25

pokepush

Pokemon Go push notifications when new Pokemon arrives in specified locations
Go
1
star
26

csgo

Dockerized CSGO Server
Makefile
1
star