diff --git a/cmd/search.go b/cmd/search.go index 98a2972e1..db2347909 100644 --- a/cmd/search.go +++ b/cmd/search.go @@ -64,8 +64,21 @@ func runSearch(cmd *Command, args []string) { } } + if len(pkgsCache) == 0 { + fmt.Printf("No result is available for keyword: %s.\n", args[0]) + return + } + isWindws := runtime.GOOS == "windows" var buf bytes.Buffer + // Print split line for more clear look. + splitLine := "<-----------------------------search results--------------------------->\n" + if !isWindws { + splitLine = strings.Replace(splitLine, "<", fmt.Sprintf(utils.PureStartColor, utils.Magenta)+"<", 1) + splitLine = strings.Replace(splitLine, ">", ">"+utils.EndColor, 1) + } + buf.WriteString(splitLine) + for k, v := range pkgsCache { // Package import path. buf.WriteString("-> " + k)