The system cannot find the path specified

Im using reactjs as front end and go as backend with mysql as its database. so inorder to parse the .js files im getting an error
The below code in parse files

func init() {
db, err = sql.Open(“mysql”, “root:root@/hrms”)
tpl, err = template.ParseFiles(“src/app/Employee/*.js”)
if err != nil {
log.Fatal(err)
}
}

my folder structure is src/app in that app folder i have different subfolders which contain js files. subfolders like src/app/home/index.js , src/app/Admin/AdminUsers.js

I have created another folder src/app/go/personalDetails.go which contain the go files

so how to access the js files through go.

Please help me out…very urgent

This will try to open the file (literally!) *.js in the folder src/app/Employee relative to the directory from where you start your program.

Perhaps you actually want to use ParseGlob instead?

Aside of that, I do not get what your question is…

It still shows the system cannot find the path

Have you read and understood the “relative to working dir” stuff?

Yes, but the problem here is if i use parseglob we need to import html/template…which throws an error as im working entire project with reactjs as frontend… so if i need to navigate or parse through the entire project …did u understand the question now?
This is the folder structure of my project

text/template has the same interface. Feel free to pick one.

You had probably to import one for your old code as well.

Also I do not know about reactjs, so I do not understand how you could create an error there.

Mostly irrelevant.

Relevant is your working directory when starting your binary.

I havent understood what u have said?

Here is my go folder which contain go files
Capture1

I undetrstood that you are using reactjs and I understood that your go code doesn’t find files.

I do not understand though, why you insist on react this way.

The first thing you need to get to run, is that templates are rendered and delivered to the client. As long as your server implemented in go does not find the templates or render them correctly, the client side is irrelevant. If and when go does its job correctly, then you can ask in a rectjs forum, why your javascript-stuff isn’t working

Also you still haven’t shown how you start your server, from where you do it and how the file tree looks from your working dir when starting the server.

Perhaps actually showing some more error messages or a minified github repository which shows your problem and process would be nice.

The react files work well wen i dont link it with go

react js files should start from the project folder through command prompt

the server starts in the above when i enter the npm start

I do not get your problem, once more…

simple i cannot parse my js files from the go file

So why do you want to parse JS files with go?

Do you want to transform them while traversing their AST? Do you simply want to send them anywhere? Do you want them to be executed in a given context?

my frontend is in reactjs so there will not be any html files. it contains only js files… so inorder to see my frontend i need to parse js files

How is your go code related to your react stuff?

Is your go code meant to be a client? Shall it serve your react application?

You said your react were working and breaks when you add golang to the mix. So what is your goal that you want to achieve by adding go?

Still you did not tell us what the working dir of the go application is when you start it, and how its surroundings look like.

Hey @srikanth32,

In my understanding you are using Javascript for UI and golang for the backend.

In order to use js files from golang you need to serve them, not parse or opening them.

package main
import (
        "net/http"
)
func main(){
        repoFrontend := "/path/to/repofrontend/"
        http.Handle("/static/",http.StripPrefix("/static/",
                http.FileServer(http.Dir(repoFrontend))))
        err := http.ListenAndServe(":9999", nil)
        if nil != err {
                panic(err)
        }
}

for example if i have a page personaldetails.js where there are textboxes to be filled…if we fill those text boxes then it should be saved to the database mysql…so im using go to save the details of my applicationor project

Capture1

The directory for my go is src/app/go/ go run personalDetails.go

But go does not need to know your JS files to do that.

Your frontend should do a request to a specified endpoint with JSON data in the body.

Your GO app does know how to treat this JSON and stores it in the database.

It does not need to know anything about your application besides the specified API.

can u tell me how to write that json … i have no idea about it

I believe what @NobbZ is trying to suggest to you is:

Your backend which would be written in go will interact with database and it will expose some APIs to handle data exchange. Ones you have all you APIs functional, your UI will be making API calls to your backend requesting user information, storing data etc.

Here is example https://medium.com/@kelvin_sp/building-and-testing-a-rest-api-in-golang-using-gorilla-mux-and-mysql-1f0518818ff6

Another possible way using java script and golang is to use the native libraries

Example https://gopherjs.github.io/playground/

Again this is general guides as I’m not familier with your application architecture. I hope that helps.