![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
github.com/kuhahalong/ddgsearch
A native Go library for DuckDuckGo search functionality. This library provides a simple and efficient way to perform searches using DuckDuckGo's search engine.
DuckDuckGo offers several advantages:
go get github.com/kuhahalong/ddgsearch
package main
import (
"context"
"fmt"
"log"
"time"
"github.com/kuhahalong/ddgsearch"
)
func main() {
// Create a new client with configuration
cfg := &ddgsearch.Config{
Timeout: 30 * time.Second,
MaxRetries: 3,
Cache: true,
}
client, err := ddgsearch.New(cfg)
if err != nil {
log.Fatal(err)
}
// Configure search parameters
params := &ddgsearch.SearchParams{
Query: "what is golang",
Region: ddgsearch.RegionUSEN,
SafeSearch: ddgsearch.SafeSearchModerate,
TimeRange: ddgsearch.TimeRangeMonth,
MaxResults: 10,
}
// Perform search
response, err := client.Search(context.Background(), params)
if err != nil {
log.Fatal(err)
}
// Print results
for i, result := range response.Results {
fmt.Printf("%d. %s\n URL: %s\n Description: %s\n\n",
i+1, result.Title, result.URL, result.Description)
}
}
// Create client with custom configuration
cfg := &ddgsearch.Config{
Timeout: 20 * time.Second,
MaxRetries: 3,
Proxy: "http://proxy:8080",
Cache: true,
Headers: map[string]string{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36",
},
}
client, err := ddgsearch.New(cfg)
params := &ddgsearch.SearchParams{
Query: "golang tutorial", // Search query
Region: ddgsearch.RegionUSEN, // Region for results (us-en, uk-en, etc.)
SafeSearch: ddgsearch.SafeSearchModerate, // Safe search level
TimeRange: ddgsearch.TimeRangeWeek, // Time filter
MaxResults: 10, // Maximum results to return
}
Available regions:
Safe search levels:
Time range options:
// HTTP proxy
cfg := &ddgsearch.Config{
Proxy: "http://proxy:8080",
}
client, err := ddgsearch.New(cfg)
// SOCKS5 proxy
cfg := &ddgsearch.Config{
Proxy: "socks5://proxy:1080",
}
client, err := ddgsearch.New(cfg)
The library includes a command-line interface (CLI) tool for easy access to DuckDuckGo search functionality.
go install github.com/kuhahalong/ddgsearch/cmd/ddgs@latest
# Basic text search
ddgs search "golang programming"
# Search news
ddgs news "golang 1.21"
For more information, see README.md
Contributions are welcome! Please feel free to submit issues and pull requests.
git clone https://github.com/kuhahalong/ddgsearch.git
go mod tidy
go test ./...
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.