#config-file #module #go #visual-studio-code

app gos

gos is a Rust project that helps you create a Go project with the modules you specify in a config file. It automatically writes the import statements in the main.go file and runs go mod init and go mod tidy for you.

6 releases

0.1.4 May 22, 2024
0.1.3 Jan 12, 2024
0.1.2 Jan 3, 2024
0.1.1 Jan 3, 2024
0.1.0 Dec 31, 2023

#231 in Development tools

Download history 3/week @ 2024-07-24 2/week @ 2024-07-31 6/week @ 2024-09-18 13/week @ 2024-09-25

374 downloads per month

GPL-3.0-or-later

48KB
882 lines

gos

gos is a tool written in Rust that helps you quickly create a Go project by specifying the Go modules you want to use in a config file. It automatically writes the import statements in the main.go file and runs go mod init and go mod tidy for you, initializing and updating your module dependencies.

中文自述在这里.

Installation

To install gos, you need to have Rust and Cargo installed on your system. You can follow the instructions here to install them.

Then, you can use Cargo to install gos from crates.io:

cargo install gos

Or, you can also clone this repository and build it from source:

git clone https://github.com/limitcool/gos.git
cd gos
cargo build --release

The executable file will be located in the target/release directory.

Usage

The first time you run gos, it will create a config file named config.yaml in the current directory, where you need to fill in the Go modules you want to use. The config file has the following format:

# The Go modules you want to use
Mods: ["github.com/charmbracelet/log"]
#  Whether to automatically create Vscode launch.json
CreateVscodeLaunch: true

You can specify any modules you want, as long as they are valid Go modules.

Then, you can run gos in the same directory to create a Go project:

gos new <project_name>

This will create a Go project with the name and modules you specified in the config file. It will also generate a main.go file with the import statements and a simple main function. For example, for the above config file, the main.go file might look like this:

package main

import (
 "github.com/charmbracelet/log"
)

func main() {
 log.Info("gos")
}

License

gos is licensed under the GPL license.

Dependencies

~4–12MB
~132K SLoC