News for hackers. Stuff that matters.
Re:./watch by PhilippGille on Saturday October 18, 2025 @07:53AM (#45626611)
One issue is when the path is not interpreted by the shell but by a program which plays by different rules.

For example in Go:

  $ cd /path/to/go/repo
  $ go run cmd/myapp
  package cmd/myapp is not in std (/usr/local/go/src/cmd/myapp)
  
  $ go run ./cmd/myapp
  Hello, World!
And then people don't want to think about when your path is for the shell and when it's a CLI param and how the CLI treats it, and just use the version that always works.
Re:./watch by Y_Y on Saturday October 18, 2025 @08:51AM (#45626951)
Thanks, this is the first good reason I've seen! Seems crazy to me that the go tool does that, but maybe I just lack sufficient unix-nature.
Re:./watch by zahlman on Saturday October 18, 2025 @09:38AM (#45627272)
This allows it to disambiguate between system path syntax and the language's syntax for symbolic names.

Similarly, package installers can use this to disambiguate between "install the local file with this exact name" and "look up a file on the index for the named package".

Re:./watch by umanwizard on Saturday October 18, 2025 @12:54PM (#45628703)
This is one of the papercuts of go that I find way more annoying than is rational.
Re:./watch by catlifeonmars on Saturday October 18, 2025 @02:02PM (#45629236)
That’s because cmd/myapp is not a local path, it’s a universal path. It makes more sense when you type go run github.com/user/name/cmd/myapp
Re:./watch by PhilippGille on Sunday October 19, 2025 @02:41PM (#45636744)
> cmd/myapp is not a local path, it’s a universal path

In `go run` the CLI interprets it as universal path, to be precise. That's exactly the point.

> go run github.com/user/name/cmd/myapp

That's not an alternative when you're working on the app's code locally. You have to use `./cmd/myapp`.

And when you do that multiple times per day/week, after a while you just start always using `./` prefix for local paths.

Re:./watch by catlifeonmars on Sunday October 19, 2025 @07:45PM (#45639017)
Would it be preferable to use a URI for go run?

For example

- go run go://cmd/foo

- go run file:///cmd/foo