go-wikipedia is a Go client library for accessing the Wikipedia API.
- Go 1.18 or higher
Using Go modules to install go-wikipedia:
go get github.com/scottzhlin/go-wikipedia
Alternatively, you can import the package directly and then run go mod tidy
to install the dependency:
import "github.com/scottzhlin/go-wikipedia/wikipedia"
package main
import (
"context"
"fmt"
"github.com/scottzhlin/go-wikipedia/wikipedia"
)
func main() {
// create a new Wikipedia client
client, err := wikipedia.NewClient()
if err != nil {
panic(err)
}
titles, err := client.Search(context.TODO(), "golang")
if err != nil {
panic(err)
}
fmt.Println(titles)
}