'Reading a Config File in Android from a Golang Bind Service

I have a Golang program from which I have created a package using gomobile bind. It creates two files abcd.jar and abcd.aar. I have copied these 2 files to the lib folder in the Android Java App in Android Studio IDE. After that I am able to run the Android app which is using the Golang program as a service. For testing the Golang service I am Posting a json file at regular intervals and this works fine. I wanted to give the "Post URL" using a json configuration file. The following starting portion of the code works, as I am receiving the posted contents on the server

    request, _ := http.NewRequest("POST", "https://example.com/path", bytes.NewBuffer(data))
    request.Header.Set("Content-Type", "application/json; charset=UTF-8")
    _, _ = client.Do(request)

But I am running into issues after that as I suspect

jsonFile, errOpen := asset.Open("service_config.json")
if errOpen != nil {
       fmt.Println(errOpen)
   }

is not working, because for testing I repeat the code for Posting the Data to the server after the above code, which is not executing and the program crashes.

I have tried placing the "service_config.json" file under:

  1. app/assets
  2. app/src/main/assets
  3. inside the golang package itself and visible in the .aar file

So is the problem due to the improper location of assets folder or do I need to give any permission for golang package to read the assets folder, or problem cause is something else? BTW, I see "fmt.Println" being used in some Golang program on the internet which is used in bind package, but wonder where the Println output can be viewed.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source