gourban

package module
v0.0.0-...-099d21b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

README

gourban Build Status GoDoc

GoLang Package for querying UrbanDictionary with minimal dependencies.

gourban provides a golang interface to the urbandictionary API. the Query(string) function returns a slice of all definitions from urbandictionary.com, and accepts single words or phrases like ["yeet", "yolo", "ok boomer"].

Simple use:

import (
    "fmt"
    
    "github.com/haukened/gourban"
)

func main() {
    ...
    definitions := gourban.Query("yeet")
    for def := range definitions {
        fmt.Printf("%s: %s\n", def.Word, def.Definition)
    }
}

Documentation

Overview

Package gourban provides a golang interface to the urbandictionary.com API. It can be imported into your codebase and used like `gourban.Query(string)` or as a standalone go binary for fun.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Definition string    `json:"definition"`
	Permalink  string    `json:"permalink"`
	Upvotes    int       `json:"thumbs_up"`
	Downvotes  int       `json:"thumbs_down"`
	Word       string    `json:"word"`
	Defid      int       `json:"defid"`
	Date       time.Time `json:"written_on"`
	Example    string    `json:"example"`
}

An Entry represents a single definition from urban dictionary. Each word can have multile entries. number of up/down votes can be used to sort definitions to most (un)popular if desired.

func First

func First(s string) (*Entry, error)

First returns a single entry that occurs first

func Query

func Query(s string) ([]Entry, error)

Query accepts a string (one word or multiples) and is URL encoded and fed to the urbandictionary API queries that do not return results return an empty slice. Upstream errors are propogated and returned, so many types may exist.

func Top

func Top(s string) (*Entry, error)

Top returns a single entry with the highest upvotes

Directories

Path Synopsis
cmd
gourban command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL