Configure GoLand for arbitrary http.FileServer path

49 Views Asked by At

You guys use Goland with net/http?
I have a mux that reveals a static directory for my static assets written like this in my net/http web-app:

    mux := http.NewServeMux()

    app.Logger.Info("starting FileServer at /static")
    fileServer := http.FileServer(http.Dir(paths.STATIC))
    mux.Handle("/static/", http.StripPrefix("/static", fileServer))

But i reference them in the html template that uses them like this:

        <link rel="stylesheet" href="/static/css/reset.css">
        <link rel="stylesheet" href="/static/css/base.css">

But because their not actually in the root directory of the project files they are high lighted and i get warnings from Goland saying it cant find them.
from problems tab

actual file is path href string is highlighted

Is there a way to make goland find them from where i specified this directory in the mux or can i atleast manually tell goland somehow so that i don't get the warnings?

1

There are 1 best solutions below

0
On

figured it out marking the file-server directory's parent dir as content-root solves it,

i was marking the actual /static dir as a content-root and it wasn't doing nothing but i guess it makes more sense for the root to be it's parent since i'm specifying static from the root.

anyway doing this; gives you context options when you trying to specify the individual files. like it give you options on what's available and i'm assuming an option to create the file there if it wasn't with the context actions shortcut alt+enter or alt+insert