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

app gos

gos是一个Rust项目,它帮助您使用在配置文件中指定的模块创建Go项目。它会自动在main.go文件中写入导入语句,并为您运行go mod init和go mod tidy。

6个版本

0.1.4 2024年5月22日
0.1.3 2024年1月12日
0.1.2 2024年1月3日
0.1.1 2024年1月3日
0.1.0 2023年12月31日

#165 in 开发工具

GPL-3.0-or-later

48KB
882 代码行

gos

gos是一个用Rust编写的工具,通过在配置文件中指定您想使用的Go模块,帮助您快速创建Go项目。它会自动在main.go文件中写入导入语句,并为您运行go mod init和go mod tidy,初始化和更新模块依赖。

中文说明见此处.

安装

要安装gos,您需要在系统上安装Rust和Cargo。您可以根据以下说明进行安装。

然后,您可以使用Cargo从crates.io安装gos

cargo install gos

或者,您也可以克隆此仓库并从源码构建

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

可执行文件将位于target/release目录中。

使用方法

第一次运行gos时,它将在当前目录中创建一个名为config.yaml的配置文件,您需要在其中填写您想使用的Go模块。配置文件格式如下

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

您可以指定任何有效的Go模块。

然后,您可以在同一目录下运行gos以创建Go项目

gos new <project_name>

这将创建一个Go项目,其名称和模块与配置文件中指定的相匹配。它还将生成一个包含导入语句和简单main函数的main.go文件。例如,对于上面的配置文件,main.go文件可能看起来像这样

package main

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

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

许可证

gos遵循GPL许可证。

依赖

~5–16MB
~137K SLoC