Skip to content

Latest commit

 

History

History
76 lines (57 loc) · 1.08 KB

README.md

File metadata and controls

76 lines (57 loc) · 1.08 KB

go-taninari

たになり語録 人生楽しんでますか?

Installation

$ go get github.com/yukirii/go-taninari/...

Usage

Command

$ taninari
$ taninari help

Library

package main

import (
	"fmt"
	"log"

	"github.com/yukirii/go-taninari"
)

func Show(msg *taninari.GorokuMessage) {
	fmt.Println(msg.PublishedAt)
	fmt.Println(msg.Text)
	if msg.ImageURL != "" {
		fmt.Println(msg.ImageURL)
	}
	fmt.Println(msg.PublishedURL)
}

func main() {
	// 語録からランダムに 1 件取得
	msg, err := taninari.GetRandomMessage()
	if err != nil {
		log.Fatal(err)
	}
	Show(msg)

	// 語録の全取得
	msgs, err := taninari.GetAllMessages()
	if err != nil {
		log.Fatal(err)
	}
	for _, msg := range msgs {
		Show(msg)
		fmt.Print("\n")
	}

	// 語録から検索
	msgs, err = taninari.SearchMessages("グレープフルーツ")
	if err != nil {
		log.Fatal(err)
	}
	for _, msg = range msgs {
		Show(msg)
		fmt.Print("\n")
	}
}

License

MIT