Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some short declarations stopped working in 6g #394

Closed
gopherbot opened this issue Dec 8, 2009 · 4 comments
Closed

Some short declarations stopped working in 6g #394

gopherbot opened this issue Dec 8, 2009 · 4 comments

Comments

@gopherbot
Copy link
Contributor

by kenliz@cruzio.com:

The following code used to compile and run, producing either a run-time error message,
or a 
list of the entries in directory "abc". Now it produces a compile time error:

undef_io_ReadDir.go:10: undefined: io.ReadDir
undef_io_ReadDir.go:15: fatal error: typecheck loop

package main
import (
        "io";
        "fmt";
)
func main() {
        dirs, err := io.ReadDir("abc");
        if err != nil {
                fmt.Println("Error reading dir: ", "abc", err);
        } else {
                for i,d := range dirs {
                        fmt.Println(i, d);
                }
        }
}

What steps will reproduce the problem?
1. Put the above code in file: undef_io_ReadDir.go
2. 6g undef_io_ReadDir.go
3. Adding "os" to the import list produces an additional error:
       undef_io_ReadDir.go:4: imported and not used: os


What is the expected output? What do you see instead?


What is your $GOOS?  $GOARCH?
darwin amd64

Which revision are you using?  (hg identify)
e205103b02e7 tip

Please provide any additional information below.
I don't know if this is a bug "fix", or a new bug. My reading of the Language
Definition and 
Efficient Go Programming is that this idiomatic style of coding was encouraged and
should 
work.
@gopherbot
Copy link
Contributor Author

Comment 1 by kenliz@cruzio.com:

This problem does not exist in the current "release" version:
     d1b75410b793 tip
 which is installed by emptying the $GOROOT directory and doing:
    hg clone -r release https://go.googlecode.com/hg/ $GOROOT
However, if one follows the instructions when submitting a new issue and does:
    hg pull -u 
and then does 
   ./all.bash
then the problem occurs...
(I was getting ready to report some problems related to channels and the scheduler when
I ran into this...)

@peterGo
Copy link
Contributor

peterGo commented Dec 8, 2009

Comment 2:

In the tip release, ReadDir is in ioutil "io/ioutil". See below:
package main
import (
    "fmt";
    ioutil "io/ioutil";
)
func main() {
    dirs, err := ioutil.ReadDir("abc");
    if err != nil {
        fmt.Println("Error reading dir: ", "abc", err);
    } else {
        for i, d := range dirs {
            fmt.Println(i , d);
        }
    }
}

@gopherbot
Copy link
Contributor Author

Comment 3 by kenliz@cruzio.com:

Thanks. So this is just a case of functionality migrating...
This can be closed.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2009

Comment 4:

I think we forgot to mention this in the release notes.  Apologies.

Owner changed to r...@golang.org.

Status changed to WontFix.

@golang golang locked and limited conversation to collaborators Jun 24, 2016
@rsc rsc removed their assignment Jun 22, 2022
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants