https://github.com/huhouhua/go-nuget
NuGet Go SDK
https://github.com/huhouhua/go-nuget
api-client client golang nuget
Last synced: about 2 months ago
JSON representation
NuGet Go SDK
- Host: GitHub
- URL: https://github.com/huhouhua/go-nuget
- Owner: huhouhua
- License: mit
- Created: 2025-04-07T13:20:07.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-07T17:33:45.000Z (about 1 year ago)
- Last Synced: 2025-04-07T17:34:46.912Z (about 1 year ago)
- Topics: api-client, client, golang, nuget
- Language: Go
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
easy golang nuget client module
Go-NuGet is a NuGet API v3 client written in Golang, enabling Golang programs to interact with NuGet repositories in a simple and unified way!
Installation ❘
Coverage ❘
Usage ❘
Examples ❘
License

[](https://github.com/huhouhua/go-nuget/blob/main/LICENSE)
[](https://github.com/huhouhua/go-nuget/releases)
[](https://godoc.org/github.com/huhouhua/go-nuget)

[](https://goreportcard.com/report/github.com/huhouhua/go-nuget)
[](https://codecov.io/gh/huhouhua/go-nuget)
## 🤘 Coverage
This API client package covers the NuGet API v3 endpoints and is updated regularly
to add new and/or missing endpoints. Currently, the following services are supported:
- [x] Service Resources
- [x] Package Search
- [x] Package Metadata
- [x] Package Publish
- [x] Package Delete
- [x] Package Download
- [x] Package Version
- [x] Package Read
- [x] Package Create
- [x] Package Dependencies
- [x] Package Source Configuration
- [x] Package Source Authentication
## 🚀 Installation and Documentation
When used with Go modules, use the following import path:
```shell
go get github.com/huhouhua/go-nuget
```
You can find the docs at [go docs](https://pkg.go.dev/github.com/huhouhua/go-nuget).
## 📄 Usage
Construct a new NuGet client, then use the various methods on the client to
access different parts of the NuGet API. For example, to get the service resources:
```go
client, err := nuget.NewClient()
if err != nil {
panic(fmt.Sprintf("Failed to create client: %v", err))
}
// Get request resource
index, _, err := client.IndexResource.GetIndex()
if err != nil {
log.Fatalf("Failed to get resources: %v", err)
}
// print the resources url
for _, r := range index.Resources {
fmt.Printf("url: %s", r.Id)
}
```
There are a few `With...` option functions that can be used to customize
the API client. For example, to set a custom source URL:
```go
client, err := nuget.NewClient(
nuget.WithSourceURL("https://your-private-feed.com/v3/index.json"),
nuget.WithRetryMax(5),
nuget.WithRetryWaitMinMax(time.Second*1, time.Second*10),
)
if err != nil {
panic(fmt.Sprintf("Failed to create client: %v", err))
}
```
## 🥙 Examples
The [examples](examples/) directory contains a couple of clear examples, of which one is partially listed here as well:
```go
package main
import (
"fmt"
"github.com/huhouhua/go-nuget"
"log"
"time"
)
func main() {
// Create a new NuGet client with custom retry settings
client, err := nuget.NewClient(
nuget.WithSourceURL("https://your-private-feed.com/v3/index.json"),
nuget.WithRetryMax(5),
nuget.WithRetryWaitMinMax(time.Second*1, time.Second*10),
)
if err != nil {
panic(fmt.Sprintf("Failed to create client: %v", err))
}
// Get all versions of a package
versions, _, err := client.FindPackageResource.ListAllVersions("MyPackage")
if err != nil {
log.Fatalf("Failed to get package versions: %v", err)
}
// print the versions
for _, v := range versions {
fmt.Printf("Found version %s", v.OriginalVersion)
}
}
```
For complete usage of go-nuget, see the full [package docs](https://godoc.org/github.com/huhouhua/go-nuget).
## Full Examples
### Full Examples : API Resources Operations
* [index.go](https://github.com/huhouhua/go-nuget/blob/main/examples/index.go)
### Full Examples : Package Find Operations
* [listversions.go](https://github.com/huhouhua/go-nuget/blob/main/examples/listversions.go)
* [getdependency.go](https://github.com/huhouhua/go-nuget/blob/main/examples/getdependency.go)
* [copynupkgtostream.go](https://github.com/huhouhua/go-nuget/blob/main/examples/copynupkgtostream.go)
### Full Examples : Package Read and Create Operations
* [readpackage.go](https://github.com/huhouhua/go-nuget/blob/main/examples/readpackage.go)
* [createpackage.go](https://github.com/huhouhua/go-nuget/blob/main/examples/createpackage.go)
### Full Examples : Package Search Operations
* [search.go](https://github.com/huhouhua/go-nuget/blob/main/examples/search.go)
### Full Examples : Package Metadata Operations
* [getmetadata.go](https://github.com/huhouhua/go-nuget/blob/main/examples/getmetadata.go)
* [listmetadata.go](https://github.com/huhouhua/go-nuget/blob/main/examples/listmetadata.go)
### Full Examples : Package Push Operations
* [pushpackage.go](https://github.com/huhouhua/go-nuget/blob/main/examples/pushpackage.go)
* [pushwithstream.go](https://github.com/huhouhua/go-nuget/blob/main/examples/pushwithstream.go)
* [deletepackage.go](https://github.com/huhouhua/go-nuget/blob/main/examples/deletepackage.go)
## 🤝 Issues
If you have an issue: report it on the [issue tracker](https://github.com/huhouhua/go-nuget/issues)
## 👤 Author
Kevin Berger ()
## 🧑💻 Contributing
Contributions are always welcome. For more information, check out the [contributing guide](CONTRIBUTING.md)
## 📘 License
Licensed under the MIT License. See [LICENSE](LICENSE) for details.