ddgo
is a Go package that provides a simple interface to query DuckDuckGo's search engine and retrieve search results. It allows you to perform searches and obtain relevant information such as titles, snippets, and URLs of the results.
To use the ddgo
package, you need to have Go installed on your machine. You can install the package using the following command:
go get github.com/evgensoft/ddgo
Here is a basic example of how to use the ddgo
package to perform a search query:
package main
import (
"fmt"
"log"
"github.com/evgensoft/ddgo"
)
func main() {
query := "Go programming language"
maxResults := 5
results, err := ddgo.Query(query, maxResults)
if err != nil {
log.Fatalf("Error querying DuckDuckGo: %v", err)
}
for _, result := range results {
fmt.Printf("Title: %s\nInfo: %s\nRef: %s\n\n", result.Title, result.Info, result.URL)
}
}
The Query
function is the main function of the package. It takes a search query and the maximum number of results to return.
query
(string): The search query string.maxResult
(int): The maximum number of results to return.
([]Result, error)
: A slice ofResult
structs containing the search results and an error if any occurred.
The Result
struct holds the data for each search result:
Title
(string): The title of the search result.Info
(string): A snippet of information about the search result.URL
(string): The URL of the search result.
The Query
function returns an error if there are issues with the HTTP request or if the response status code is not 200. Make sure to handle errors appropriately in your application.
This project is licensed under the MIT License. See the LICENSE file for more details.
Contributions are welcome! If you have suggestions for improvements or find bugs, please open an issue or submit a pull request.