go/tool: go serve [directory] ???

51 views
Skip to first unread message

atd...@gmail.com

unread,
7:03 AM (10 hours ago) 7:03 AM
to golang-nuts
Just wondering if a default command to serve files locally was ever discussed?

I just realized that because of javascript CSP I often need a local server to view some index.html file  especially if it imports some other modules.

I could easily write a go file to do so (or even have AI do it if I am not afraid of my brain cells shrinking, which I am a little) and install it.

But I thought that the right spot for this could be the go tool.

Did I miss something and it is already existing, or is it insecure perhaps?

For instance, by default, "go serve . " could run a local file server on port 3000 or something...?

Sean Liao

unread,
7:31 AM (10 hours ago) 7:31 AM
to golang-nuts
This just seems too far out of scope? 
The go command is for developing go programs.
A serve command would be for web work, written in files that are not go.
If you're developing a web server, then it's more appropriate to run the web server itself.

- sean

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/3b8063ad-c3c9-4276-9d7f-8e747dcba8bfn%40googlegroups.com.

Mikk Margus

unread,
7:37 AM (10 hours ago) 7:37 AM
to golan...@googlegroups.com
The compiler toolchain does not seem like a good place to bundle
something like this.
You could just find a project that implements this and then `go run` it
instead.

e.g
go run github.com/kevinpollet/se...@v0.0.0-20220109170338-5759ed9d6e12
> --
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to golang-nuts...@googlegroups.com <mailto:golang-
> nuts+uns...@googlegroups.com>.
> To view this discussion visit https://groups.google.com/d/msgid/golang-
> nuts/3b8063ad-c3c9-4276-9d7f-8e747dcba8bfn%40googlegroups.com <https://
> groups.google.com/d/msgid/golang-nuts/3b8063ad-
> c3c9-4276-9d7f-8e747dcba8bfn%40googlegroups.com?
> utm_medium=email&utm_source=footer>.

Message has been deleted

robert engels

unread,
12:36 PM (5 hours ago) 12:36 PM
to atd...@gmail.com, golang-nuts
It’s like 3 lines of code… I think you can handle it. 

On Jan 24, 2026, at 6:47 AM, atd...@gmail.com <atd...@gmail.com> wrote:

@Sean
That's fair.  Makes sense.

@Mikk
Yeah my rationale was that I wouldn't want to trust some random program from the internet either. Integrating it to the tooling would be a tiny bit more secure.
But it gets out of scope quickly I guess.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/7f11889a-275d-4e4d-a981-5651cb3539b4n%40googlegroups.com.

Michael Oguidan

unread,
3:40 PM (2 hours ago) 3:40 PM
to golang-nuts
Why do you want to rely on AI, when you are a good programmer.
About what you are asking, i think it will be a good idea to build it because never heard of something like this in Go

pchapman

unread,
3:44 PM (2 hours ago) 3:44 PM
to Michael Oguidan, golang-nuts
Consider the Air Live Reload project:  https://github.com/air-verse/air


--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.

atd...@gmail.com

unread,
4:15 PM (1 hour ago) 4:15 PM
to golang-nuts
I know :) but since the go tool is already installed and having the facility available by default on node and python, I thought maybe I had missed something.
It was between using npx serve . or using go and having to find a package or write the lines myself.
Just to check a html file that could not run in file mode.

Anyway, I kept my braincells activity for some other stuff... Seems to work still https://github.com/atdiar/fsrv


**oops I think I've deleted my previous response, saying that basically ruling it out of scope made sense, and that the rationale was avoiding third party package that might be changed under people's feet**
Reply all
Reply to author
Forward
0 new messages