Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shuienko/go-pihole
Go client for Pi-Hole API v3.0+
https://github.com/shuienko/go-pihole
go gohole pi-hole
Last synced: 16 days ago
JSON representation
Go client for Pi-Hole API v3.0+
- Host: GitHub
- URL: https://github.com/shuienko/go-pihole
- Owner: shuienko
- License: mit
- Created: 2018-01-30T10:51:20.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-12-04T19:45:57.000Z (about 1 year ago)
- Last Synced: 2024-11-13T13:08:47.893Z (about 2 months ago)
- Topics: go, gohole, pi-hole
- Language: Go
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-pihole [![Go Report Card](https://goreportcard.com/badge/github.com/shuienko/go-pihole)](https://goreportcard.com/report/github.com/shuienko/go-pihole)
Go client for Pi-Hole API v3.0+## Documentation
Available here: [![GoDoc](https://godoc.org/github.com/shuienko/go-pihole?status.svg)](https://godoc.org/github.com/shuienko/go-pihole)## Example
```go
package mainimport (
"fmt"
"log"
"os""github.com/shuienko/go-pihole"
)func main() {
// Get environment variables
piholeHost, ok := os.LookupEnv("PIHOLE_HOST")
if !ok {
log.Fatal("PIHOLE_HOST environment variable in NOT set")
}apiToken, ok := os.LookupEnv("PIHOLE_TOKEN")
if !ok {
log.Fatal("PIHOLE_TOKEN environment variable is NOT set")
}
// Create connector object
ph := gohole.PiHConnector{
Host: piholeHost,
Token: apiToken,
}// Get Pi-Hole Summary
summary := ph.Summary()
// Print AdsBlocked (last 24h)
fmt.Println(summary.AdsBlocked)// Print statistics
summary.Show()// Enable Pi-Hole
err := ph.Enable()
if err != nil {
panic("Error")
}}
```