0

for parsing reactjs file PersonalDetails.js

template.Must(template.ParseGlob("PersonalDetails.js"))

but its showing

panic: html/template: pattern matches no files: PersonalDetails.js

Ramesh
  • 1
  • 3
  • Make sure `PersonalDetails.js` is in the working directory, or also provide its path. Also to parse a template file (or multiple files) given by their names, use `template.ParseFiles()`. – icza Jun 14 '18 at 07:31
  • is it possible to integrate go with reactjs as frontend and mysql as its database – Ramesh Jun 14 '18 at 07:37
  • Yes it is, why wouldn't it be? – icza Jun 14 '18 at 07:42
  • i cant do it ....can u help me out privately – Ramesh Jun 14 '18 at 07:44
  • func init() { db, err = sql.Open("mysql", "root:root@/hrms") tpl, err = template.ParseFiles("src/app/index.js") if err != nil { log.Fatal(err) } //tpl = template.New("").ParseFiles("src/*") } – Ramesh Jun 18 '18 at 10:22
  • 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. – Ramesh Jun 18 '18 at 10:24
  • If yo want to parse files given by a glob such as `src/*`, you have to use `ParseGlob()`, you can't use `ParseFiles()` then, only if you explicitly list the file names. – icza Jun 18 '18 at 10:33
  • when i use parseglob it shows the following error Error loading templates:html/template: pattern matches no files: `src/app/*.js` – Ramesh Jun 18 '18 at 11:16
  • Then my very first comment applies again. – icza Jun 18 '18 at 11:18
  • can u be more specific i cant get what u have said – Ramesh Jun 18 '18 at 11:20
  • The error means the pattern matches no files. This is because the path is relative, and it is resolved to the working directory. Either your working directory is not what you think, or that relative path is wrong. – icza Jun 18 '18 at 11:21
  • My project directory is Project/src/app/.....in the app folder there are different subfolders like src/app/admin/AdminUsers.js or src/app/Employee/AddEmployee.js........and my go file is in src/app/go/details.go – Ramesh Jun 18 '18 at 11:26
  • The working directory is the folder from which you launch your app. So `src/app/*.js` must exist compared to that folder. Or use absolute path. – icza Jun 18 '18 at 11:31
  • Please see related question: [how to reference a relative file from code and tests](https://stackoverflow.com/questions/31059023/how-to-reference-a-relative-file-from-code-and-tests/31059125#31059125) – icza Jun 18 '18 at 11:32
  • i have around 100 js files to be parsed – Ramesh Jun 18 '18 at 11:34

0 Answers0