File tree Expand file tree Collapse file tree 7 files changed +22
-8
lines changed
Expand file tree Collapse file tree 7 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,8 @@ import (
1212 "github.com/pkg/errors"
1313
1414 "github.com/oleg-balunenko/advent-of-code/puzzles"
15- _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions/2019/day01"
15+ // register all solutions
16+ _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions"
1617)
1718
1819const (
Original file line number Diff line number Diff line change 1- package solutions
1+ package puzzles
22
33import (
44 "errors"
Original file line number Diff line number Diff line change 1- package solutions
1+ package puzzles
22
33import (
44 "os"
@@ -12,6 +12,7 @@ func TestMakeName(t *testing.T) {
1212 year string
1313 puzzle string
1414 }
15+
1516 tests := []struct {
1617 name string
1718 args args
@@ -46,7 +47,10 @@ func TestMakeName(t *testing.T) {
4647 wantErr : true ,
4748 },
4849 }
50+
4951 for _ , tt := range tests {
52+ tt := tt
53+
5054 t .Run (tt .name , func (t * testing.T ) {
5155 got , err := MakeName (tt .args .year , tt .args .puzzle )
5256 if tt .wantErr {
Original file line number Diff line number Diff line change @@ -9,15 +9,14 @@ import (
99 "github.com/pkg/errors"
1010
1111 "github.com/oleg-balunenko/advent-of-code/puzzles"
12- "github.com/oleg-balunenko/advent-of-code/puzzles/solutions"
1312)
1413
1514type solution struct {
1615 name string
1716}
1817
1918func init () {
20- puzzleName , err := solutions .MakeName ("2019" , "day01" )
19+ puzzleName , err := puzzles .MakeName ("2019" , "day01" )
2120 if err != nil {
2221 panic (err )
2322 }
Original file line number Diff line number Diff line change 1- // Package declares common interface for puzzle solutions and functionality for register and run them .
1+ // Package solutions registers solutions of puzzles .
22//
3- // Each solution should implement `Solver` interface, be implemented udnder separate package and contain `init()`
3+ // Each solution should implement `Solver` interface, be implemented under separate package and contain `init()`
44// function that will register that solution in list of all solvers.
55//
66// Example:
2020// }
2121//
2222// Then to register solution in the list of all solutions: make a blank import of package with puzzle solution
23- // at main .go
23+ // at register .go
2424//
2525// import _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions/day01"
26+ //
27+ // And then blank import solutions package at main.go to register all solutions
28+ //
29+ // import _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions
2630package solutions
Original file line number Diff line number Diff line change 1+ package solutions
2+
3+ import (
4+ _ "github.com/oleg-balunenko/advent-of-code/puzzles/solutions/2019/day01" // register day01 solution
5+ )
Original file line number Diff line number Diff line change 1+ // Package puzzles declares common interface for puzzle solutions and functionality for register and run them.
12package puzzles
23
34import (
You can’t perform that action at this time.
0 commit comments