query

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package query はソート時に使われるデフォルトの質問集です。

"query.json" を Unmarshal したものを返すだけのパッケージですが、この JSON ファイ ルはバイナリに埋め込まれます。

"query.json" を最新版に更新する場合は `go generate ./...` を実行してください。(要 `curl`)

また、この "query.json" ファイルは https://git.io/JMPFq からダウンロードして埋め 込まれるため、** "query.json" ファイルは直接編集しないでください**。以下のリポジ トリに PR してください。

https://github.com/KEINOS/QiiTaskQuery

Index

Examples

Constants

This section is empty.

Variables

View Source
var EmbeddedQuery []byte

EmbeddedQuery はバイナリに埋め込まれたデフォルトの質問データです。

Functions

func Description

func Description(key string) string

Description は指定された key の質問集の説明文を返します。(query.json の "key.description" 要素の値)

該当する key が存在しない場合は空の文字列を返します。指定可能な key は List() 関数で取得してください。

Example
package main

import (
	"fmt"

	"github.com/Qithub-BOT/QiiTask/core/query"
)

func main() {
	fmt.Println("Description of 'task' query:", query.Description("task"))
	fmt.Println("Description of 'likes' query:", query.Description("likes"))

}
Output:

Description of 'task' query: ものごとの整理向けの質問(作業タスクなど)
Description of 'likes' query: 好きなものの整理向けの質問(コレクションなど)

func List

func List() []string

List は選択可能な質問集のキー名を返します。

Example
package main

import (
	"fmt"

	"github.com/Qithub-BOT/QiiTask/core/query"
)

func main() {
	list := query.List()

	for i := 0; i < len(list); i++ {
		value := list[i]

		if value == "task" {
			fmt.Println("the list 'task' was found in the embedded data")

			continue
		}

		if value == "likes" {
			fmt.Println("the list 'likes' was found in the embedded data")

			continue
		}
	}

}
Output:

the list 'task' was found in the embedded data
the list 'likes' was found in the embedded data

Types

type Query

type Query struct {
	Description string   `json:"description,omitempty" mapstructure:"description"`
	Objective   []string `json:"客観的な質問,omitempty" mapstructure:"客観的な質問"`
	Subjective  []string `json:"主観的な質問,omitempty" mapstructure:"主観的な質問"`
}

Query は各質問一覧を定義する構造体です。

func New

func New(key string) (Query, error)

New は指定された key 名の質問集を返します。指定可能な key は List() 関数で取 得してください。

Example
package main

import (
	"fmt"
	"log"

	"github.com/Qithub-BOT/QiiTask/core/query"
)

func main() {
	obj, err := query.New("task")
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println("質問の説明:", obj.Description)
	fmt.Println("客観的な質問[0]:", obj.Objective[0])
	fmt.Println("主観的な質問[0]:", obj.Subjective[0])

}
Output:

質問の説明: ものごとの整理向けの質問(作業タスクなど)
客観的な質問[0]: どちらが重要ですか
主観的な質問[0]: いま手を付けたいのはどちらですか

type Samples

type Samples map[string]Query

Samples は同梱されている全ての質問一覧を保持する構造体です。

Jump to

Keyboard shortcuts

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