PeernetOfficial / core

Core library. Use this to create a new Peernet application.
MIT License
36 stars 5 forks source link

added function to modify config file #82

Closed Akilan1999 closed 2 years ago

Akilan1999 commented 2 years ago

Added possibility to modify configuration using a function.

Ex:

package main

import (
    "fmt"
    "github.com/PeernetOfficial/core"
    "os"
)

func init() {
    if _, err := core.LoadConfig("/tmp/Config.yaml"); err != nil {
        fmt.Printf("Error loading config file: %s", err.Error())
        os.Exit(core.ExitErrorConfigAccess)
    }

    // modify config file
    var modify core.ModifyConfig
    modify.SearchIndex = "/tmp/data/search_Index/"
    modify.BlockchainGlobal = "/tmp/data/blockchain/"
    modify.BlockchainMain = "/tmp/data/blockchain_main/"
    modify.WarehouseMain = "/tmp/data/warehouse/"
    modify.GeoIPDatabase = "/tmp/data/GeoLite2-City.mmdb"
    modify.LogFile = "/tmp/data/log.txt"

    // Change config modification
    modify.ModifyConfig()

    core.InitLog()
    core.Init("Your application/1.0")
}

func main() {
    core.Connect()
}
Kleissner commented 2 years ago

Config loading (and saving) code has been changed in the latest version. Please check if any changes are still needed, otherwise we can close this PR.