Skip to content
This repository has been archived by the owner on Mar 22, 2022. It is now read-only.

Commit

Permalink
Merge pull request #38 from kytrinyx/linting
Browse files Browse the repository at this point in the history
Fix golint complaints
  • Loading branch information
Katrina Owen authored Jul 30, 2017
2 parents 2c49de1 + 242959c commit bf07f1f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/spf13/cobra"
)

// Version is the current version of the tool.
const Version = "3.1.0"

// versionCmd represents the version command
Expand Down
5 changes: 5 additions & 0 deletions track/exercise_readme.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ var (
pathExerciseInsertDeprecated = "HINTS.md"
)

// ExerciseReadme contains the data necessary to generate a README
// for an Exercism exercise.
type ExerciseReadme struct {
Spec *ProblemSpecification
Hints string
Expand All @@ -31,6 +33,7 @@ type ExerciseReadme struct {
dir string
}

// NewExerciseReadme locates and reads all the data to create an ExerciseReadme.
func NewExerciseReadme(root, trackID, slug string) (ExerciseReadme, error) {
readme := ExerciseReadme{
trackDir: filepath.Join(root, trackID),
Expand Down Expand Up @@ -58,6 +61,7 @@ func NewExerciseReadme(root, trackID, slug string) (ExerciseReadme, error) {
return readme, nil
}

// Generate produces a README from the template and data.
func (readme ExerciseReadme) Generate() (string, error) {
t, err := template.New("readme").Parse(readme.template)
if err != nil {
Expand All @@ -69,6 +73,7 @@ func (readme ExerciseReadme) Generate() (string, error) {
return bb.String(), nil
}

// Write generates and writes the README to a file.
func (readme ExerciseReadme) Write() error {
s, err := readme.Generate()
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions track/problem_specification.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var (
ProblemSpecificationsPath string
)

// ProblemSpecification contains metadata describing an exercise.
type ProblemSpecification struct {
Slug string
Description string
Expand All @@ -31,6 +32,9 @@ type ProblemSpecification struct {
specPath string
}

// NewProblemSpecification loads the specification from files on disk.
// It will default to a custom specification, falling back to the generic specification
// if no custom one is found.
func NewProblemSpecification(root, trackID, slug string) (*ProblemSpecification, error) {
spec := &ProblemSpecification{
root: root,
Expand All @@ -53,6 +57,7 @@ func (spec *ProblemSpecification) Name() string {
return strings.Title(strings.Join(strings.Split(spec.Slug, "-"), " "))
}

// Credits are a markdown-formatted version of the source of the exercise.
func (spec *ProblemSpecification) Credits() string {
if spec.SourceURL == "" {
return spec.Source
Expand Down

0 comments on commit bf07f1f

Please sign in to comment.