News for hackers. Stuff that matters.
Re:Hurl, the Exceptional Language by jakewins on Sunday May 26, 2024 @04:18PM (#40485050)
Wait I’m so confused by this - this is the opposite of how I thought it worked? Go import creates exactly the symbol you mention in the import statement, like “import fmt” creates a symbol “fmt”?

Can you give an example of what you mean?

Re:Hurl, the Exceptional Language by sweeter on Sunday May 26, 2024 @06:38PM (#40486051)
Yea, this is correct.

    ```go
    import (
       "net/http"
       "os"

       "github.com/anacrolix/torrent"
       tstor "github.com/anacrolix/torrent/storage"
    )
```

would import as: http, os, torrent and tstor. That guy is mixed up.

Re:Hurl, the Exceptional Language by remram on Monday May 27, 2024 @10:44AM (#40491205)
I don't know what this proves. See example above for an example of exactly what I've said.
Re:Hurl, the Exceptional Language by thiht on Monday May 27, 2024 @02:21AM (#40488141)
The only example I have in mind is modules, which can have a different name from their root package.

For example you can have github.com/user/go-module as module name, and "module" as package name, so "import github.com/user/go-module" will be imported as "module.*".

There’s a linter that automatically aliases this kind of imports with their actual module name so that it’s non ambiguous when reading the import list.

Re:Hurl, the Exceptional Language by remram on Monday May 27, 2024 @10:42AM (#40491184)
Here's an example, a package bar under a totally different name:

    package main

    // imports 'bar', you couldn't possibly know from reading this line
    import "github.com/remram44/foo20240527"

    func main() {
        // ??? where does this function come from ???
        bar.SomeFunc()
    }