Use pointer receiver more offen
This commit is contained in:
parent
6999b4e728
commit
c7569b5e54
59 changed files with 688 additions and 672 deletions
|
|
@ -22,7 +22,7 @@ type importHint struct {
|
|||
FlagsDeps []int64
|
||||
}
|
||||
|
||||
func buildExerciceHints(i Importer, exercice fic.Exercice) (hints []importHint, errs []string) {
|
||||
func buildExerciceHints(i Importer, exercice *fic.Exercice) (hints []importHint, errs []string) {
|
||||
params, _, err := parseExerciceParams(i, exercice.Path)
|
||||
if err != nil {
|
||||
errs = append(errs, fmt.Sprintf("%q: challenge.txt: %s", path.Base(exercice.Path), err))
|
||||
|
|
@ -102,19 +102,19 @@ func buildExerciceHints(i Importer, exercice fic.Exercice) (hints []importHint,
|
|||
}
|
||||
|
||||
// CheckExerciceHints checks if all hints are corrects..
|
||||
func CheckExerciceHints(i Importer, exercice fic.Exercice) ([]importHint, []string) {
|
||||
func CheckExerciceHints(i Importer, exercice *fic.Exercice) ([]importHint, []string) {
|
||||
return buildExerciceHints(i, exercice)
|
||||
}
|
||||
|
||||
// SyncExerciceHints reads the content of hints/ directories and import it as EHint for the given challenge.
|
||||
func SyncExerciceHints(i Importer, exercice fic.Exercice, flagsBindings map[int64]fic.Flag) (hintsBindings map[int]fic.EHint, errs []string) {
|
||||
func SyncExerciceHints(i Importer, exercice *fic.Exercice, flagsBindings map[int64]fic.Flag) (hintsBindings map[int]*fic.EHint, errs []string) {
|
||||
if _, err := exercice.WipeHints(); err != nil {
|
||||
errs = append(errs, err.Error())
|
||||
} else {
|
||||
hints, berrs := buildExerciceHints(i, exercice)
|
||||
errs = append(errs, berrs...)
|
||||
|
||||
hintsBindings = map[int]fic.EHint{}
|
||||
hintsBindings = map[int]*fic.EHint{}
|
||||
|
||||
for _, hint := range hints {
|
||||
// Import hint
|
||||
|
|
@ -143,9 +143,9 @@ func SyncExerciceHints(i Importer, exercice fic.Exercice, flagsBindings map[int6
|
|||
func ApiGetRemoteExerciceHints(ps httprouter.Params, _ []byte) (interface{}, error) {
|
||||
theme, errs := BuildTheme(GlobalImporter, ps.ByName("thid"))
|
||||
if theme != nil {
|
||||
exercice, _, _, _, errs := BuildExercice(GlobalImporter, *theme, path.Join(theme.Path, ps.ByName("exid")), nil)
|
||||
exercice, _, _, _, errs := BuildExercice(GlobalImporter, theme, path.Join(theme.Path, ps.ByName("exid")), nil)
|
||||
if exercice != nil {
|
||||
hints, errs := CheckExerciceHints(GlobalImporter, *exercice)
|
||||
hints, errs := CheckExerciceHints(GlobalImporter, exercice)
|
||||
if hints != nil {
|
||||
return hints, nil
|
||||
} else {
|
||||
|
|
|
|||
Reference in a new issue