Installation
This guide covers different ways to install and set up the NuGet Config Parser library in your Go project.
Requirements
- Go Version: 1.19 or later
- Operating System: Windows, Linux, or macOS
- Dependencies: No external dependencies required
Installation Methods
Using Go Modules (Recommended)
The easiest way to install the library is using Go modules:
go get github.com/scagogogo/nuget-config-parser
This will download the latest version of the library and add it to your go.mod
file.
Specific Version
To install a specific version:
go get github.com/scagogogo/nuget-config-parser@v1.0.0
Latest Development Version
To get the latest development version from the main branch:
go get github.com/scagogogo/nuget-config-parser@main
Importing the Library
Once installed, import the library in your Go code:
import "github.com/scagogogo/nuget-config-parser/pkg/nuget"
For specific packages:
import (
"github.com/scagogogo/nuget-config-parser/pkg/nuget"
"github.com/scagogogo/nuget-config-parser/pkg/types"
"github.com/scagogogo/nuget-config-parser/pkg/parser"
"github.com/scagogogo/nuget-config-parser/pkg/editor"
)
Verification
Create a simple test file to verify the installation:
// test_installation.go
package main
import (
"fmt"
"github.com/scagogogo/nuget-config-parser/pkg/nuget"
)
func main() {
api := nuget.NewAPI()
fmt.Println("NuGet Config Parser installed successfully!")
// Try to find a config file
configPath, err := api.FindConfigFile()
if err != nil {
fmt.Println("No config file found, but library is working!")
} else {
fmt.Printf("Found config file: %s\n", configPath)
}
}
Run the test:
go run test_installation.go
Project Setup
Initialize a New Project
If you're starting a new project:
mkdir my-nuget-project
cd my-nuget-project
go mod init my-nuget-project
go get github.com/scagogogo/nuget-config-parser
Add to Existing Project
If you have an existing Go project:
cd your-existing-project
go get github.com/scagogogo/nuget-config-parser
IDE Setup
VS Code
For VS Code users, make sure you have the Go extension installed. The library should work out of the box with IntelliSense and auto-completion.
GoLand
GoLand should automatically recognize the library after running go get
. If you encounter issues, try:
- File → Invalidate Caches and Restart
- Ensure Go modules are enabled in Settings → Go → Go Modules
Other IDEs
Most Go-compatible IDEs should work with the library automatically. Ensure your IDE supports Go modules.
Troubleshooting
Common Issues
Module Not Found
If you get a "module not found" error:
go: module github.com/scagogogo/nuget-config-parser: not found
Make sure you have:
- Go modules enabled (
go mod init
if needed) - Internet connection for downloading
- Correct module path
Version Conflicts
If you encounter version conflicts:
go mod tidy
go get github.com/scagogogo/nuget-config-parser@latest
Proxy Issues
If you're behind a corporate proxy:
go env -w GOPROXY=direct
go env -w GOSUMDB=off
Or configure your proxy settings:
go env -w GOPROXY=https://your-proxy.com
Verification Commands
Check your Go environment:
go version
go env GOMOD
go env GOPROXY
List installed modules:
go list -m all | grep nuget-config-parser
Build Tags
The library doesn't require any special build tags, but you can use standard Go build tags for platform-specific code:
//go:build windows
// +build windows
// Windows-specific code
Docker Usage
If you're using Docker, add the library to your Dockerfile:
FROM golang:1.21-alpine
WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download
# The library will be downloaded with other dependencies
COPY . .
RUN go build -o main .
CMD ["./main"]
Performance Considerations
The library is designed to be lightweight with no external dependencies. However, for optimal performance:
- Use the API instance efficiently (create once, reuse)
- Cache parsed configurations when possible
- Use position-aware editing for minimal file changes
Next Steps
Now that you have the library installed:
- Read the Getting Started guide
- Try the Quick Start examples
- Explore the API Reference for detailed documentation
- Check out Examples for real-world usage patterns