common

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const CommandName = "sync"
View Source
const CommandUsage = "同步远程数据保存到本地 sqlite 数据库"
View Source
const GoCommandName = "sync-go"
View Source
const GoCommandUsage = "同步远程 go package 保存到本地 sqlite 数据库"
View Source
const GoTagName = "go-package"
View Source
const Owner = "xiaoxuan6"
View Source
const Repo = "resource"
View Source
const SqlitePath = "rsearch.db"

Variables

View Source
var (
	Client *github.Client
)
View Source
var DB *gorm.DB
View Source
var FgColor = map[string][]string{
	"github":   {"github", "GitHub"},
	"color":    {"color", "Color"},
	"api":      {"api", "Api", "API"},
	"markdown": {"markdown", "Markdown"},
	"json":     {"json", "JSON"},
	"sql":      {"sql", "SQL"},
	"tool":     {"tool", "Tool"},
	"cli":      {"cli", "CLI"},
}

Functions

func Clear

func Clear() (err error)

func CloseDb

func CloseDb()

func Count

func Count() int64

func CreateInBatches

func CreateInBatches(models []Model) (err error)

func DeleteByTag

func DeleteByTag(tag string) error

func FetchRepositoryContent added in v0.1.1

func FetchRepositoryContent() []*github.RepositoryContent

func FetchUrlContent added in v0.1.1

func FetchUrlContent(ctx context.Context, filename string) ([]byte, string, error)

func Flush

func Flush() (err error)

func Get added in v0.1.1

func Get(url string) ([]byte, error)

func GetToken added in v0.1.0

func GetToken(token string) string

func InitDb

func InitDb(dsn string)

func NewClient added in v0.1.1

func NewClient(token string)

func SpinnerStart added in v0.1.0

func SpinnerStart(prefix string)

func SpinnerStop added in v0.1.0

func SpinnerStop()

Types

type Model

type Model struct {
	Title string `json:"title"`
	Tag   string `json:"tag"`
	Url   string `json:"url"`
}

func All

func All() (model []*Model, err error)

func FetchModelByTag

func FetchModelByTag(tag string) (model []*Model, err error)

func FetchModelByTitle

func FetchModelByTitle(title string) (model []*Model, err error)
func Search(keyword string) (model []*Model, err error)

func SearchWithTag

func SearchWithTag(keyword, tag string) (model []*Model, err error)

func (*Model) Insert

func (model *Model) Insert() (err error)

Jump to

Keyboard shortcuts

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