hidrocor

commit 42179bc40cef556eb9f8d14ec263b6b31cf451e4

Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>

wiki: set a default file for looking up and generate proper errors

 wiki.go | 19 +++++++++++--------


diff --git a/wiki.go b/wiki.go
index 68d86d9aebe1bfb3e0b081c6085e9ebc5e74246a..6aab0d66da7952ee65b4134f8e9e94eec7bc883f 100644
--- a/wiki.go
+++ b/wiki.go
@@ -2,20 +2,21 @@ // This package holds the logic for reading a dir, finding out the main file,
 // etc. It's a mere abstraction on top of the wiki's filesystem. When fed with
 // a path, it'll return a read file for markdown consumption
 
-package hidrocor
+package main
 
 import (
+	"errors"
 	"os"
 	"path"
 )
 
-func Lookup(wikiPath string, docPath string) (*file.File, error) {
-	if path == "" {
-		path = "README.md"
+func Lookup(wikiPath string, docPath string) ([]byte, error) {
+	if docPath == "" {
+		docPath = "README.md"
 	}
 
 	routePath := path.Join(wikiPath, docPath)
-	fileInfo, err := os.Stat(docPath)
+	fileInfo, err := os.Stat(routePath)
 
 	if err != nil {
 		return nil, err
@@ -29,12 +30,12 @@ 		}
 
 		for _, file := range files {
 			switch file.Name() {
-				case
+			case
 				"index.md",
 				"INDEX.md",
 				"readme.md",
 				"README.md":
-				source, err = os.ReadFile(path.Join(routePath, file.Name()))
+				source, err := os.ReadFile(path.Join(routePath, file.Name()))
 
 				if err != nil {
 					return nil, err
@@ -44,7 +45,7 @@ 				return source, nil
 			}
 		}
 	} else {
-		source, err = os.ReadFile(routePath)
+		source, err := os.ReadFile(routePath)
 
 		if err != nil {
 			return nil, err
@@ -52,4 +53,6 @@ 		}
 
 		return source, nil
 	}
+
+	return nil, errors.New("Something wen't really wrong")
 }