| Crates.io | vx-tool-go |
| lib.rs | vx-tool-go |
| version | 0.4.0 |
| created_at | 2025-06-15 03:59:38.61001+00 |
| updated_at | 2025-06-19 13:54:22.200028+00 |
| description | Go tool support for vx |
| homepage | https://github.com/loonghao/vx |
| repository | https://github.com/loonghao/vx |
| max_upload_size | |
| id | 1712890 |
| size | 81,894 |
Go Programming Language Tool Plugin for vx Universal Tool Manager
Fast Go development with beautiful installation experience and zero configuration
vx-tool-go provides Go programming language support for vx, enabling automatic installation, version management, and execution of Go commands through the vx interface.
# Build and run
vx go build
vx go run main.go
vx go run .
# Module management
vx go mod init mymodule
vx go mod tidy
vx go mod download
vx go mod verify
# Testing
vx go test
vx go test ./...
vx go test -v -race
# Code formatting and tools
vx go fmt ./...
vx go vet ./...
vx go clean
# Get packages
vx go get github.com/gin-gonic/gin
vx go get -u github.com/gin-gonic/gin@latest
vx go get ./...
# List modules
vx go list -m all
vx go list -m -versions github.com/gin-gonic/gin
# Install binaries
vx go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
# Build for different platforms
vx go build -o myapp
GOOS=linux GOARCH=amd64 vx go build -o myapp-linux
GOOS=windows GOARCH=amd64 vx go build -o myapp.exe
# Generate code
vx go generate ./...
# Documentation
vx go doc fmt.Println
vx go doc -http=:6060
# Install latest version
vx install go
# Install specific version
vx install go@1.21.6
vx install go@1.20.12
# Install latest version
vx install go@latest
# Semantic version ranges
vx install go@^1.21.0 # Latest 1.21.x
vx install go@~1.21.6 # Latest 1.21.6.x
vx install go@>=1.20.0 # 1.20.0 or higher
[tools]
go = "1.21.6" # Specific version
# go = "latest" # Latest stable
# go = "^1.21.0" # Version range
[tools.go]
auto_install = true
[tools.go]
default_version = "latest"
auto_install = true
install_timeout = 300
[go.settings]
GOPATH = "~/go"
GOPROXY = "https://proxy.golang.org,direct"
GOSUMDB = "sum.golang.org"
GOPRIVATE = ""
# Set through vx configuration or environment
export GOPATH=$HOME/go
export GOPROXY=https://proxy.golang.org,direct
export GOSUMDB=sum.golang.org
export GOPRIVATE=example.com/private
# Build-specific
export CGO_ENABLED=1
export GOOS=linux
export GOARCH=amd64
# vx automatically sets GOROOT
vx go env GOROOT # Points to vx-managed Go installation
# Other Go environment variables
vx go env GOPATH
vx go env GOPROXY
vx go env GOMODCACHE
# List all supported platforms
vx go tool dist list
# Common cross-compilation examples
GOOS=windows GOARCH=amd64 vx go build -o app.exe
GOOS=darwin GOARCH=arm64 vx go build -o app-mac-arm64
GOOS=linux GOARCH=arm64 vx go build -o app-linux-arm64
#!/bin/bash
# build-all.sh
platforms=("windows/amd64" "darwin/amd64" "darwin/arm64" "linux/amd64" "linux/arm64")
for platform in "${platforms[@]}"
do
platform_split=(${platform//\// })
GOOS=${platform_split[0]}
GOARCH=${platform_split[1]}
output_name='myapp-'$GOOS'-'$GOARCH
if [ $GOOS = "windows" ]; then
output_name+='.exe'
fi
env GOOS=$GOOS GOARCH=$GOARCH vx go build -o $output_name
done
use vx_core::{Tool, ToolManager};
use vx_tool_go::GoTool;
let go_tool = GoTool::new();
let manager = ToolManager::new();
// Install Go
manager.install_tool(&go_tool, "1.21.6").await?;
// Execute Go commands
manager.execute_tool(&go_tool, &["version"]).await?;
use vx_core::{Plugin, PluginManager};
use vx_tool_go::GoPlugin;
let plugin = GoPlugin::new();
let mut manager = PluginManager::new();
manager.register_plugin(Box::new(plugin))?;
cd crates/vx-tool-go
cargo build
cargo test
# Test with actual Go installation
cargo test --features integration-tests
.vx.toml for version specification# Initialize new Go module
vx go mod init myapp
# Create main.go
cat > main.go << EOF
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
EOF
# Build and run
vx go build
./myapp
# Initialize module
vx go mod init mywebapp
# Add dependencies
vx go get github.com/gin-gonic/gin
# Create server
cat > main.go << EOF
package main
import "github.com/gin-gonic/gin"
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.JSON(200, gin.H{"message": "Hello, World!"})
})
r.Run(":8080")
}
EOF
# Run
vx go run main.go
# Reinstall Go
vx install go@1.21.6 --force
# Clear module cache
vx go clean -modcache
# Reset modules
vx go mod tidy
# Use system Go as fallback
vx --use-system-path go version
# Check available versions
vx search go
# Verify installation
vx go version
vx go env
# Check GOROOT
vx go env GOROOT
# Force reinstall
vx remove go@1.21.6
vx install go@1.21.6
# Check Go environment
vx go env
# Verify module
vx go mod verify
vx go mod tidy
# Clean build cache
vx go clean -cache
vx go clean -modcache
# Debug build
vx go build -x -v
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please see the contributing guidelines for more information.
vx-core - Core functionalityvx-cli - Command-line interfacevx-tool-node - Node.js toolvx-tool-rust - Rust tool