<commit_before>package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"net/http"
	"os"
	"os/exec"
	"strings"
)

const (
	apiSearch  = "http://go-search.org/api?action=search&q=%s"
	apiPackage = "http://go-search.org/api?action=package&id=%s"
)

type Search struct {
	Query string
	Hits  []Package
}

func search(query string) error {
	resp, err := http.Get(fmt.Sprintf(apiSearch, query))
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	var s Search
	if err := json.Unmarshal(body, &s); err != nil {
		return err
	}
	for _, p := range s.Hits {
		fmt.Printf("%s %s\n", p.StaticRank, p.Package, p.Synopsis)
	}
	return nil
}

func show(id string) error {
	resp, err := http.Get(fmt.Sprintf(apiPackage, id))
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	var p Package
	if err := json.Unmarshal(body, &p); err != nil {
		return err
	}
	fmt.Printf("Name: %s\n", p.Name)
	fmt.Printf("Package: %s\n", p.Package)
	fmt.Printf("Project URL: %s\n", p.ProjectURL)
	fmt.Printf("Rank: %d\n", p.StaticRank)
	fmt.Printf("Description:\n%s\n%s\n", strings.Repeat("-", 12), p.Description)
	if p.Imports != nil {
		fmt.Println("\nDepends:")
		for _, v := range p.Imports {
			fmt.Printf("\t%s\n", v)
		}
	}
	return nil
}<commit_msg>make the search formatting nicer to read<commit_after>package main

import (
	"encoding/json"
	"fmt"
	"go/doc"
	"io/ioutil"
	"net/http"
	"net/url"
	"os"
	"os/exec"
	"strings"
)

const (
	apiSearch  = "http://go-search.org/api?action=search&q=%s"
	apiPackage = "http://go-search.org/api?action=package&id=%s"
)

type Search struct {
	Query string
	Hits  []Package
}

func search(query string) error {
	resp, err := http.Get(fmt.Sprintf(apiSearch, url.QueryEscape(query)))
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	var s Search
	if err := json.Unmarshal(body, &s); err != nil {
		return err
	}
	for _, p := range s.Hits {
		fmt.Printf("%s\n\n", p.Package)
		doc.ToText(os.Stdout, p.Synopsis, "  ", "", 74)
		fmt.Printf("\n")
	}
	return nil
}

func show(id string) error {
	resp, err := http.Get(fmt.Sprintf(apiPackage, id))
	if err != nil {
		return err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return err
	}
	var p Package
	if err := json.Unmarshal(body, &p); err != nil {
		return err
	}
	fmt.Printf("Name: %s\n", p.Name)
	fmt.Printf("Package: %s\n", p.Package)
	fmt.Printf("Project URL: %s\n", p.ProjectURL)
	fmt.Printf("Rank: %d\n", p.StaticRank)
	fmt.Printf("Description:\n%s\n%s\n", strings.Repeat("-", 12), p.Description)
	if p.Imports != nil {
		fmt.Println("\nDepends:")
		for _, v := range p.Imports {
			fmt.Printf("\t%s\n", v)
		}
	}
	return nil
}
{'fraction_non_alphanumeric': 0.1854810698159083, 'fraction_numerical': 0.0020840569642236887, 'mean_word_length': 3.47900466562986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '147537', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1199, 'n_words': 269}