package main import ( "archive/tar" "context" "crypto/sha256" "crypto/tls" "errors" "fmt" "io" "log" "net/http" "os" "path" "path/filepath" "strconv" "strings" "sync" "time" "git.cheetah.cat/worksucc/gma-puzzles/common" adriver "github.com/arangodb/go-driver" ahttp "github.com/arangodb/go-driver/http" "github.com/labstack/echo/v4" "github.com/twinj/uuid" ) var ( PoolMaxItems = 500 PoolPathFinal = "/mnt/SC9000/storagePools" PoolPathTemp = "/mnt/ramfs/" ) type Pool struct { PoolID string `json:"_key"` Finalized bool `json:"finalized"` ReadOnly bool `json:"readOnly"` Size uint64 `json:"size"` //folder string `json:"-"` itemCount int items []string wormMode bool filePath string file *os.File //tarWriter *tar.Writer tarReader *tar.Reader } type PoolFile struct { FileID string Size uint64 } type PoolMaster struct { cachePath string finalPath string CurrentPool *Pool lock sync.Mutex LocalPools []*Pool FullPools []*Pool WORMPools map[string]*Pool } type PoolPackResult struct { PoolID string Files []string FileCount int Size int64 Hash string outputFileName string } var ( arangoDB adriver.Database arangoCTX context.Context colChunk adriver.Collection colFile adriver.Collection colFile2Chunk adriver.Collection // PoolMaster poolMaster PoolMaster ) func ConnectDB(baseURL string, arangoUser string, arangoPWD string, arangoDatabase string) (driver adriver.Database, ctx context.Context, err error) { log.Println("connectDB:", "Starting Connection Process...") // Retry Loop for Failed Connections for i := 0; i < 6; i++ { if i == 5 { return driver, ctx, fmt.Errorf("connectdb: unable to connect to database %d times!", i) } else if i > 0 { time.Sleep(30 * time.Second) } // Connect to ArangoDB URL conn, err := ahttp.NewConnection(ahttp.ConnectionConfig{ Endpoints: []string{baseURL}, TLSConfig: &tls.Config{ /*...*/ }, }) if err != nil { log.Println("connectDB:", "Cannot Connect to ArangoDB!", err) continue } // Connect Driver to User client, err := adriver.NewClient(adriver.ClientConfig{ Connection: conn, Authentication: adriver.BasicAuthentication(arangoUser, arangoPWD), }) if err != nil { log.Println("connectDB:", "Cannot Authenticate ArangoDB User!", err) continue } // Create Context for Database Access ctx = context.Background() driver, err = client.Database(ctx, arangoDatabase) if err != nil { log.Println("connectDB:", "Cannot Load ArangoDB Database!", err) continue } log.Println("connectDB:", "Connection Sucessful!") return driver, ctx, nil } return driver, ctx, fmt.Errorf("connectDB: FUCK HOW DID THIS EXCUTE?") } func InitDatabase() (err error) { arangoDB, arangoCTX, err = ConnectDB("http://192.168.45.8:8529/", "gma-inator", "gma-inator", "gma-inator") colChunk, err = arangoDB.Collection(arangoCTX, "chunk") if err != nil { return err } colFile, err = arangoDB.Collection(arangoCTX, "file") if err != nil { return err } colFile2Chunk, err = arangoDB.Collection(arangoCTX, "file_chunk_map") if err != nil { return err } return nil } func (p *Pool) OpenTar() (err error) { p.wormMode = true outputDir := filepath.Join(poolMaster.cachePath, "worm", p.PoolID) err = os.MkdirAll(outputDir, os.ModePerm) if err != nil { return err } p.file, err = os.Open(p.filePath) if err != nil { return err } p.items = []string{} p.tarReader = tar.NewReader(p.file) for { header, err := p.tarReader.Next() if err == io.EOF { break } if err != nil { return err } path := filepath.Join(outputDir, header.Name) info := header.FileInfo() file, err := os.OpenFile(path, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, info.Mode()) if err != nil { return err } defer file.Close() _, err = io.Copy(file, p.tarReader) if err != nil { return err } p.items = append(p.items, header.Name) fmt.Print(".") } return nil } func (p *Pool) Fetch(id string, writer io.Writer) (err error) { for _, poolItem := range p.items { if poolItem == id { fmt.Printf("Fetch WORMPool %s\n", id) poolLocalFilePath := filepath.Join(poolMaster.cachePath, "worm", p.PoolID, id) srcLocalFile, err := os.Open(poolLocalFilePath) if err != nil { return err } defer srcLocalFile.Close() if _, err = io.Copy(writer, srcLocalFile); err != nil { return err } return nil } } return fmt.Errorf("%s not found", id) } func NewPoolMaster(finalPath string, cachePath string) (poolMaster PoolMaster, err error) { poolMaster.finalPath = finalPath poolMaster.cachePath = cachePath poolMaster.WORMPools = make(map[string]*Pool) //poolMaster.lock = sync.Mutex{} destPath := filepath.Join(poolMaster.cachePath, "pool") err = os.MkdirAll(destPath, os.ModePerm) if err != nil { return poolMaster, err } destPath = filepath.Join(poolMaster.cachePath, "worm") err = os.MkdirAll(destPath, os.ModePerm) if err != nil { return poolMaster, err } err = os.MkdirAll(poolMaster.finalPath, os.ModePerm) if err != nil { return poolMaster, err } return poolMaster, nil } func (p *PoolMaster) NewPool() (*Pool, error) { var err error pool := Pool{} pool.PoolID = uuid.NewV4().String() pool.Finalized = false pool.ReadOnly = false //TODO : Sync to DB destPath := filepath.Join(p.cachePath, "pool", pool.PoolID) //dir := filepath.Dir(destPath) err = os.MkdirAll(destPath, os.ModePerm) if err != nil { return &pool, err } return &pool, nil } func (p *PoolMaster) GetCurrentWriteablePool() (pool *Pool, err error) { //fmt.Printf("Current Pool %s, ItemCount = %d\n", pool.PoolID, pool.itemCount) if p.CurrentPool != nil && p.CurrentPool.itemCount >= PoolMaxItems { fmt.Printf("Aquiring Lock for GetCurrentWriteablepool\n") p.lock.Lock() defer p.lock.Unlock() defer fmt.Printf("unlock GetCurrentWriteablepool\n") fmt.Printf("Aquired Lock success for GetCurrentWriteablepool\n") p.CurrentPool.ReadOnly = true p.FullPools = append(p.FullPools, p.CurrentPool) // queue for compression fmt.Printf("GetCurrentWriteablePool(): current Pool (%s) is full (%d), creating new one\n", p.CurrentPool.PoolID, p.CurrentPool.itemCount) p.CurrentPool = nil } if p.CurrentPool == nil { fmt.Printf("Creating new Pool") p.CurrentPool, err = p.AcquireNewOrRecoverPool() fmt.Printf("... got [%s]\n", p.CurrentPool.PoolID) if err != nil { return pool, err } } return p.CurrentPool, nil } func RestorePoolFromFolder(folderPath string) (pool *Pool, err error) { pool = &Pool{} pool.PoolID = path.Base(folderPath) entries, err := os.ReadDir(folderPath) if err != nil { return pool, err } for _, e := range entries { if !e.IsDir() { pool.items = append(pool.items, e.Name()) pool.itemCount++ } } pool.ReadOnly = pool.itemCount >= PoolMaxItems pool.Finalized = false // we are still local return pool, err } func (p *PoolMaster) ScanForLocalPools() (err error) { fmt.Printf("Aquiring Lock for ScanForLocalPools\n") p.lock.Lock() defer p.lock.Unlock() defer fmt.Printf("unlock ScanForLocalPools\n") fmt.Printf("Aquired Lock success for ScanForLocalPools\n") entries, err := os.ReadDir(filepath.Join(p.cachePath, "pool")) if err != nil { return err } for _, e := range entries { if e.IsDir() { fmt.Printf("Scanning For Local Pools, found %s:", e.Name()) tarFinalPath := filepath.Join(p.finalPath, fmt.Sprintf("%s.tar", e.Name())) _, err = os.Stat(tarFinalPath) finalPathExists := false if err != nil { if !errors.Is(err, os.ErrNotExist) { return err } } dboChunkExists, err := colChunk.DocumentExists(arangoCTX, e.Name()) if err != nil { return err } if dboChunkExists { var dboChunk common.DB_Chunk _, err := colChunk.ReadDocument(arangoCTX, e.Name(), &dboChunk) if err != nil { return err } finalPathExists = dboChunk.Finalized && dboChunk.ReadOnly && !dboChunk.NotReady fmt.Printf("is in DB readonly %v finalized %v notready %v itemCount=%d size=%d hash=%s\n", dboChunk.ReadOnly, dboChunk.Finalized, dboChunk.NotReady, dboChunk.FileCount, dboChunk.Size, dboChunk.Hash) if finalPathExists { fmt.Println("skipping") } } if finalPathExists { continue } poolDirPath := filepath.Join(p.cachePath, "pool", e.Name()) restoredPool, err := RestorePoolFromFolder(poolDirPath) if err != nil { return err } fmt.Printf("is readonly %v itemCount=%d\n", restoredPool.ReadOnly, restoredPool.itemCount) p.LocalPools = append(p.LocalPools, restoredPool) } } return nil } // Pool Packing func (p *PoolMaster) ImportPoolPackResult(packResult PoolPackResult) (err error) { startTime := time.Now() dboChunk := common.DB_Chunk{ ID: packResult.PoolID, Hash: packResult.Hash, Size: packResult.Size, FileCount: packResult.FileCount, NotReady: true, ReadOnly: true, Finalized: true, } var dboChunk2File []common.DB_File2Chunk for _, prFile := range packResult.Files { dboChunk2File = append(dboChunk2File, common.DB_File2Chunk{ ID: prFile, File: fmt.Sprintf("file/%s", prFile), Chunk: fmt.Sprintf("chunk/%s", dboChunk.ID), }) } _, err = colChunk.CreateDocument(arangoCTX, dboChunk) if err != nil { return err } chunkSize := 500 for { if len(dboChunk2File) == 0 { break } // necessary check to avoid slicing beyond // slice capacity if len(dboChunk2File) < chunkSize { chunkSize = len(dboChunk2File) } _, errorSlice, _ := colFile2Chunk.CreateDocuments(arangoCTX, dboChunk2File[0:chunkSize]) //metaSlice, errorSlice, _ := colFile2Chunk.CreateDocuments(arangoCTX, dboChunk2File[0:chunkSize]) //fmt.Println("Metaslice") //fmt.Println(metaSlice) /*for _, meta := range metaSlice { if !meta.ID.IsEmpty() { newUnknownFiles = append(newUnknownFiles, meta.Key) fileIDs = append(fileIDs, meta.Key) } }*/ for _, createError := range errorSlice { if createError != nil && strings.Contains(createError.Error(), "unique constraint violated - in index primary of type primary over '_key'") { } else if createError != nil { return createError } } dboChunk2File = dboChunk2File[chunkSize:] } fmt.Printf("ImportPool Duration %dms\n", time.Since(startTime).Milliseconds()) return nil } func (p *PoolMaster) MovePoolPackToWORM(packResult PoolPackResult) (err error) { startTime := time.Now() targetFileName := filepath.Join(p.finalPath, fmt.Sprintf("%s.tar", packResult.PoolID)) err = common.MoveFile(packResult.outputFileName, targetFileName) if err != nil { return err } tarFileCheck, err := os.Open(targetFileName) if err != nil { return err } defer tarFileCheck.Close() shaHasher := sha256.New() _, err = io.Copy(shaHasher, tarFileCheck) if err != nil { return err } wormHash := fmt.Sprintf("%x", shaHasher.Sum(nil)) fmt.Printf("WORMTarPool hash is %s , old is %s\n", wormHash, packResult.Hash) if wormHash != packResult.Hash { os.Remove(targetFileName) return err } fmt.Printf("MoveWORM Duration %dms\n", time.Since(startTime).Milliseconds()) return nil } func (p *PoolMaster) PackPool(poolID string) (packResult PoolPackResult, err error) { startTime := time.Now() packResult.PoolID = poolID fmt.Printf("Aquiring Lock for PackPool(%s)\n", poolID) p.lock.Lock() defer p.lock.Unlock() defer fmt.Printf("unlock PackPool\n") fmt.Printf("Aquired Lock success for PackPool(%s)\n", poolID) packResult.outputFileName = filepath.Join(p.cachePath, "pool", fmt.Sprintf("%s.tar", poolID)) tarFile, err := os.Create(packResult.outputFileName) if err != nil { return packResult, err } defer tarFile.Close() tw := tar.NewWriter(tarFile) defer tw.Close() entries, err := os.ReadDir(filepath.Join(p.cachePath, "pool", poolID)) if err != nil { return packResult, err } //fmt.Printf("len(entries) == %d\n", len(entries)) if len(entries) != PoolMaxItems { return packResult, fmt.Errorf("Pool contains %d items, but there should be %d", len(entries), PoolMaxItems) } for _, e := range entries { originalPath := filepath.Join(p.cachePath, "pool", poolID, e.Name()) file, err := os.Open(originalPath) if err != nil { return packResult, err } defer file.Close() info, err := file.Stat() if err != nil { return packResult, err } tarFileHeader, err := tar.FileInfoHeader(info, info.Name()) if err != nil { return packResult, err } err = tw.WriteHeader(tarFileHeader) if err != nil { return packResult, err } _, err = io.Copy(tw, file) if err != nil { return packResult, err } packResult.FileCount++ packResult.Files = append(packResult.Files, e.Name()) } err = tw.Flush() if err != nil { return packResult, err } err = tarFile.Close() if err != nil { return packResult, err } // re-open and check tarFileCheck, err := os.Open(packResult.outputFileName) if err != nil { return packResult, err } defer tarFileCheck.Close() shaHasher := sha256.New() hashedBytes, err := io.Copy(shaHasher, tarFileCheck) if err != nil { return packResult, err } packResult.Hash = fmt.Sprintf("%x", shaHasher.Sum(nil)) fmt.Printf("PackPoolTar hash is %s\n", packResult.Hash) packFileStats, err := tarFileCheck.Stat() if err != nil { return packResult, err } packResult.Size = packFileStats.Size() if hashedBytes != packResult.Size { return packResult, fmt.Errorf("WORM Copy HashedBytes %d != FileSize %d", hashedBytes, packResult.Size) } fmt.Printf("PackPool Duration %dms\n", time.Since(startTime).Milliseconds()) return packResult, nil } func (p *PoolMaster) AcquireNewOrRecoverPool() (pool *Pool, err error) { // p.NewPool() for _, localPool := range p.LocalPools { if !localPool.ReadOnly && localPool.itemCount < 500 { return localPool, nil } } return p.NewPool() } func (p *PoolMaster) Lookup(id string) (exists bool) { // TODO: DB check if p.CurrentPool != nil { // CurrentPool for _, poolItem := range p.CurrentPool.items { if poolItem == id { return true } } } for _, wormPool := range p.WORMPools { // WORM Pools for _, poolItem := range wormPool.items { if poolItem == id { return true } } } for _, fullPool := range p.FullPools { // Full Pools for _, poolItem := range fullPool.items { if poolItem == id { return true } } } for _, localPool := range p.LocalPools { // Local Pools for _, poolItem := range localPool.items { if poolItem == id { return true } } } // TODO : DB Check // ArangoDB dboFile2ChunkExists, err := colFile2Chunk.DocumentExists(arangoCTX, id) if err != nil { return false } return dboFile2ChunkExists } func (p *PoolMaster) FetchLoadWORM(chunkID string, fileID string, writer io.Writer) (err error) { fmt.Printf("FetchLoadWORM(chunkID %s, fileID %s, ...)\n", chunkID, fileID) // search within loaded worm-pools for wormID, wormPool := range p.WORMPools { if wormID != chunkID { continue } for _, poolItem := range wormPool.items { if poolItem == fileID { fmt.Printf("Fetch WORMPool %s file %s\n", wormID, fileID) return wormPool.Fetch(fileID, writer) } } break } // else load wormPool into disk-cache extract to "worm" // wormMode fmt.Printf("Aquiring Lock for FetchLoadWORM\n") p.lock.Lock() defer p.lock.Unlock() defer fmt.Printf("unlock FetchLoadWORM\n") fmt.Printf("Aquired Lock success for FetchLoadWORM\n") var dboChunk common.DB_Chunk _, err = colChunk.ReadDocument(arangoCTX, chunkID, &dboChunk) if err != nil { return err } loadedWormPool := Pool{ PoolID: dboChunk.ID, Size: uint64(dboChunk.Size), ReadOnly: dboChunk.ReadOnly, Finalized: dboChunk.Finalized, filePath: filepath.Join(p.finalPath, fmt.Sprintf("%s.tar", dboChunk.ID)), } fmt.Println("initialized loadedWormPool, Opening tar...") err = loadedWormPool.OpenTar() if err != nil { return err } fmt.Println("extracted") p.WORMPools[loadedWormPool.PoolID] = &loadedWormPool return loadedWormPool.Fetch(fileID, writer) //return nil } func (p *PoolMaster) Fetch(id string, writer io.Writer) (err error) { if p.CurrentPool != nil { for _, poolItem := range p.CurrentPool.items { if poolItem == id { fmt.Printf("Fetch CurrentPool %s\n", id) poolLocalFilePath := filepath.Join(p.cachePath, "pool", p.CurrentPool.PoolID, id) //fmt.Println(poolLocalFilePath) //fmt.Printf("%s %s\n", p.CurrentPool.PoolID, poolItem) srcLocalFile, err := os.Open(poolLocalFilePath) if err != nil { return err } //fmt.Println("Closer") defer srcLocalFile.Close() //fmt.Println("io.Copy") if _, err = io.Copy(writer, srcLocalFile); err != nil { return err } return nil } } } for _, wormPool := range p.WORMPools { for _, poolItem := range wormPool.items { if poolItem == id { fmt.Printf("Fetch WORMPool %s file %s\n", wormPool.PoolID, id) return wormPool.Fetch(id, writer) } } } for _, fullPool := range p.FullPools { for _, poolItem := range fullPool.items { if poolItem == id { fmt.Printf("Fetch FullPool %s\n", id) poolLocalFilePath := filepath.Join(p.cachePath, "pool", fullPool.PoolID, id) srcLocalFile, err := os.Open(poolLocalFilePath) if err != nil { return err } defer srcLocalFile.Close() if _, err = io.Copy(writer, srcLocalFile); err != nil { return err } return nil } } } for _, localPool := range p.LocalPools { for _, poolItem := range localPool.items { if poolItem == id { fmt.Printf("Fetch LocalPool %s\n", id) poolLocalFilePath := filepath.Join(p.cachePath, "pool", localPool.PoolID, id) srcLocalFile, err := os.Open(poolLocalFilePath) if err != nil { return err } defer srcLocalFile.Close() if _, err = io.Copy(writer, srcLocalFile); err != nil { return err } return nil } } } // ArangoDB dboFile2ChunkExists, err := colFile2Chunk.DocumentExists(arangoCTX, id) if err != nil { return err } fmt.Printf("dboFile2ChunkExists %s = %v\n", id, dboFile2ChunkExists) if dboFile2ChunkExists { var dboFile2Chunk common.DB_File2Chunk _, err = colFile2Chunk.ReadDocument(arangoCTX, id, &dboFile2Chunk) if err != nil { return err } //FetchFromPoolPack //dboFile2Chunk.Chunk <- which chunk i need to find return p.FetchLoadWORM(dboFile2Chunk.Chunk[6:], id, writer) } return nil } func (p *PoolMaster) Store(id string, src io.Reader, targetSize int64) (err error) { pool, err := p.GetCurrentWriteablePool() if err != nil { return err } if pool.ReadOnly { return fmt.Errorf("WTF Pool %s is ReadOnly but GetCurrentWriteablePool returned it", pool.PoolID) } fmt.Printf("Store(%s)\n", id) fmt.Printf("Aquiring Lock for Store\n") p.lock.Lock() defer p.lock.Unlock() defer fmt.Printf("unlock Store\n") fmt.Printf("Aquired Lock success for Store\n") // figuring out paths poolFolder := filepath.Join(p.cachePath, "pool", pool.PoolID) destPath := filepath.Join(poolFolder, id) dst, err := os.Create(destPath) if err != nil { _ = os.Remove(destPath) return err } defer dst.Close() // copy from ioReader to file writtenBytes, err := io.Copy(dst, src) if err != nil { _ = os.Remove(destPath) return err } if writtenBytes != targetSize { _ = os.Remove(destPath) return err } // check transferred data dst.Seek(0, 0) shaHasher := sha256.New() if _, err := io.Copy(shaHasher, dst); err != nil { return err } outputHash := fmt.Sprintf("%x", shaHasher.Sum(nil)) if outputHash != id { return fmt.Errorf("Store() Sha256 Hash Mismatch") } pool.itemCount++ pool.items = append(pool.items, id) fmt.Printf("Current Pool %s, ItemCount = %d\n", pool.PoolID, pool.itemCount) entries, err := os.ReadDir(poolFolder) if err != nil { return err } newItemCount := 0 for _, e := range entries { if !e.IsDir() { pool.items = append(pool.items, e.Name()) newItemCount++ } } pool.itemCount = newItemCount fmt.Printf("Current Pool %s, Recounted ItemCount = %d\n", pool.PoolID, pool.itemCount) if pool.itemCount >= PoolMaxItems { pool.ReadOnly = true } return nil } func removeFromSlice(slice []*Pool, s int) []*Pool { return append(slice[:s], slice[s+1:]...) } func main() { err := InitDatabase() if err != nil { panic(err) } poolMaster, err = NewPoolMaster(PoolPathFinal, PoolPathTemp) if err != nil { panic(err) } // Scan for local existing Pools err = poolMaster.ScanForLocalPools() if err != nil { panic(err) } go func() { for { for index, fullPool := range poolMaster.FullPools { poolMaster.lock.Lock() packResult, err := poolMaster.PackPool(fullPool.PoolID) if err != nil { panic(err) } err = poolMaster.ImportPoolPackResult(packResult) if err != nil { panic(err) } err = poolMaster.MovePoolPackToWORM(packResult) if err != nil { panic(err) } os.RemoveAll(filepath.Join(poolMaster.cachePath, "pool", fullPool.PoolID)) poolMaster.FullPools = removeFromSlice(poolMaster.FullPools, index) poolMaster.lock.Unlock() } time.Sleep(time.Second * 10) } }() for _, localPool := range poolMaster.LocalPools { if localPool.ReadOnly { dboChunkExists, err := colChunk.DocumentExists(arangoCTX, localPool.PoolID) if err != nil { panic(err) } if !dboChunkExists { fmt.Printf("Packing Pool %s\n", localPool.PoolID) packResult, err := poolMaster.PackPool(localPool.PoolID) if err != nil { panic(err) } err = poolMaster.ImportPoolPackResult(packResult) if err != nil { panic(err) } err = poolMaster.MovePoolPackToWORM(packResult) if err != nil { panic(err) } os.RemoveAll(filepath.Join(poolMaster.cachePath, "pool", localPool.PoolID)) } //os.RemoveAll(filepath.Join(poolMaster.cachePath, "pool", localPool.PoolID)) } // packResult.FileCount } e := echo.New() //e.Use(middleware.Logger()) e.GET("/", func(c echo.Context) error { return c.String(http.StatusOK, "Hello, World!") }) e.GET("/fetch/:id", func(c echo.Context) error { id := c.Param("id") exists := poolMaster.Lookup(id) if exists { c.Response().Header().Set(echo.HeaderContentType, echo.MIMEOctetStream) c.Response().WriteHeader(http.StatusOK) err = poolMaster.Fetch(id, c.Response()) if err != nil { fmt.Printf("%v", err) return c.String(http.StatusInternalServerError, err.Error()) } c.Response().Flush() } else { fmt.Printf("/fetch/%s does not exist\n", id) return c.String(http.StatusNotFound, "Not Found") } return nil //return c.Stream(200, "application/x-octet-stream", nil) }) e.POST("/stash/:id/:size", func(c echo.Context) error { id := c.Param("id") sizeStr := c.Param("size") sizeVal, err := strconv.ParseInt(sizeStr, 10, 64) if err != nil { fmt.Println(err) return c.String(http.StatusExpectationFailed, "Error") } exists := poolMaster.Lookup(id) if exists { fmt.Printf("/stash/%s exists already\n", id) return c.String(http.StatusAlreadyReported, "Exists already") } fmt.Printf("stashing %s", id) file, err := c.FormFile("file") if err != nil { fmt.Println(err) return c.String(http.StatusExpectationFailed, "Error") } formStream, err := file.Open() if err != nil { fmt.Println(err) return c.String(http.StatusExpectationFailed, "Error") } defer formStream.Close() err = poolMaster.Store(id, formStream, sizeVal) if err != nil { fmt.Println(err) return c.String(http.StatusExpectationFailed, "Error") } fmt.Println("...stashed") return c.JSON(http.StatusOK, true) }) e.Logger.Fatal(e.Start(":13371")) }