gosearch

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

README

gosearch

一个命令行下查询go mod的小工具

使用方式

  1. 克隆代码
    git clone 
    
  2. 安装
    go install cmd/gosearch.go
    
  3. 使用
    gosearch [flags] keyword[[, ]keywords...]
    # examples
    gosearch gin
    gosearch gin,cobra
    gosearch gin cobra
    gosearch -s gin cobra
    gosearch -r gin cobra
    

Documentation

Index

Constants

View Source
const (
	RenderName = 1 << iota
	RenderImportPath
	RenderLicense
	RenderSynopsis
	RenderHomeSite
)
View Source
const RenderUndefined = 0

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFormatter

type DefaultFormatter struct {
	*ShortFormatter
}

func NewDefaultFormatter

func NewDefaultFormatter(options ...FormatterOption) *DefaultFormatter

func (*DefaultFormatter) Format

func (f *DefaultFormatter) Format(p Package) string

type Formatter

type Formatter interface {
	Format(p Package) string
}

Formatter print a pretty Package description

type FormatterOption

type FormatterOption func(f *ShortFormatter)

func NotRenderEmpty

func NotRenderEmpty() FormatterOption

func NotRenderTitle

func NotRenderTitle() FormatterOption

func RenderParts

func RenderParts(flags ...int) FormatterOption

type Package

type Package struct {
	// 包名称
	Name string

	// 导入路径
	ImportPath string

	// 主页
	HomeSite string

	// 概要信息
	Synopsis string

	// 许可证
	License string
}

Package 代指一个Go模块

type Searcher

type Searcher interface {
	Search(ctx context.Context, keyword string) ([]Package, error)
}

Searcher 查询器,给定关键字查询相关go mod

func NewOfficialSearcher

func NewOfficialSearcher(cli *http.Client) Searcher

type ShortFormatter

type ShortFormatter struct {
	// contains filtered or unexported fields
}

func NewShortFormatter

func NewShortFormatter(options ...FormatterOption) *ShortFormatter

func (*ShortFormatter) Format

func (s *ShortFormatter) Format(p Package) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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