<commit_before>package view

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

// Render has API URL and API body.
type Render struct {
	URL    string
	Reader io.Reader
}

/*
Item is base on parsing Qiita API JSON.
DOCS: https://qiita.com/api/v2/docs#get-apiv2itemsitem_id
*/
type Item struct {
	Markdown string `json:"body"`
	Title    string `json:"title"`
	URL      string `json:"url"`
}

/*
NewRender creates Render.
URL is Qiita item API URL for getting content.
*/
func NewRender(url string) *Render {
	return &Render{
		URL: url,
	}
}

// GetPage set response body.
func (r *Render) GetPage() error {
	res, err := http.Get(r.URL)
	if err != nil {
		return err
	}
	defer res.Body.Close()

	r.Reader = res.Body<commit_msg>Fix close event when it only err response<commit_after>package view

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

// Render has API URL and API body.
type Render struct {
	URL    string
	Reader io.Reader
}

/*
Item is base on parsing Qiita API JSON.
DOCS: https://qiita.com/api/v2/docs#get-apiv2itemsitem_id
*/
type Item struct {
	Markdown string `json:"body"`
	Title    string `json:"title"`
	URL      string `json:"url"`
}

/*
NewRender creates Render.
URL is Qiita item API URL for getting content.
*/
func NewRender(url string) *Render {
	return &Render{
		URL: url,
	}
}

// GetPage set response body.
func (r *Render) GetPage() error {
	res, err := http.Get(r.URL)
	if err != nil {
		res.Body.Close()
		return err
	}

	r.Reader = res.Body
{'fraction_non_alphanumeric': 0.13138686131386862, 'fraction_numerical': 0.0026542800265428003, 'mean_word_length': 3.2598870056497176, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '1403750', 'n_tokens_mistral': 574, 'n_tokens_neox': 564, 'n_words': 175}