<commit_before>package proto

import (
	pb "code.google.com/p/goprotobuf/proto"
	"errors"
	"io/ioutil"
	"net/http"
)

func NewSlug(name string, version string, stages int) (slug *Slug, err error) {
	slug = &Slug{
		Name:         pb.String(name),
		Version:      pb.String(version),
		Transformers: make([]*Transform, stages),
	}

	return
}

func NewSlugFromFile(filename string) (slug *Slug, err error) {
	var data []byte

	data, err = ioutil.ReadFile(filename)
	if err != nil {
		return
	}

	slug = &Slug{}
	err = pb.Unmarshal(data, slug)
	if err != nil {
		return
	}

	return
}

func NewSlugFromURL(url string) (slug *Slug, err error) {
	var data []byte
	var resp *http.Response

	resp, err = http.Get(url)
	if resp.StatusCode != 200 {
		err = errors.New("Couldn't load slug from " + url)
		return
	}
	if err != nil {
		return
	}
<commit_msg>adding an error check in slug.go<commit_after>package proto

import (
	pb "code.google.com/p/goprotobuf/proto"
	"errors"
	"io/ioutil"
	"net/http"
)

func NewSlug(name string, version string, stages int) (slug *Slug, err error) {
	slug = &Slug{
		Name:         pb.String(name),
		Version:      pb.String(version),
		Transformers: make([]*Transform, stages),
	}

	return
}

func NewSlugFromFile(filename string) (slug *Slug, err error) {
	var data []byte

	data, err = ioutil.ReadFile(filename)
	if err != nil {
		return
	}

	slug = &Slug{}
	err = pb.Unmarshal(data, slug)
	if err != nil {
		return
	}

	return
}

func NewSlugFromURL(url string) (slug *Slug, err error) {
	var data []byte
	var resp *http.Response

	resp, err = http.Get(url)
	if err != nil {
		return
	}

	if resp.StatusCode != 200 {
		err = errors.New("Couldn't load slug from " + url)
		return
	}

{'fraction_non_alphanumeric': 0.1375878220140515, 'fraction_numerical': 0.00351288056206089, 'mean_word_length': 3.404639175257732, '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': '6727770', 'n_tokens_mistral': 694, 'n_tokens_neox': 663, 'n_words': 177}