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 ¶
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 ¶
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]: いま手を付けたいのはどちらですか
Click to show internal directories.
Click to hide internal directories.