first your 404 is file not found, not is route 404.
state 1: your file error.
if /
and /example
is dir, your request access fild is ../frontend/public/index.html
and ../frontend/public/exampme/index.html
,please look net/http/fs.go source code.
/a.js
-> ../frontend/public/a.js
[root@localhost tmp]# ls -R bruhurb/ frontend/
bruhurb/:
main.go
frontend/:
public
frontend/public:
example index.html
frontend/public/example:
index.html
[root@localhost tmp]# cat frontend/public/index.html
1
[root@localhost tmp]# cat frontend/public/example/index.html
2
[root@localhost tmp]# cd bruhurb/
[root@localhost bruhurb]# ls
main.go
[root@localhost bruhurb]# go run main.go
2020/04/08 22:42:53 Listening on http://locahost:8080
state 2: your workdir is tmp dir or workdir is err.
add code fmt.Println(os.Args[0])
show workdir.
if use go run
cmd start server, GO use a tmp dir run, workdir is tmp else relative path is invalid, so file is 404.
please use go build
and start server in workdir, or add os.Chdir
to workdir.