undefined: ioutil.Stat

233 views
Skip to first unread message

Soham

unread,
Mar 23, 2010, 10:08:55 PM3/23/10
to golang-nuts
Hi all,

sorry to bother with mickey mouse kinda syntax but I am not able to
get this. I am just trying to fool around with this language.

For the following code

package main

import (
"fmt"
"io/ioutil"
)

func main() {
if c, d := ioutil.Stat(os.Args[1]); d == nil {
for i := 0; i < len(c); i++ {
fmt.Println(os.Args[1], " is a directory and file description is ",
c[i].Uid, c[i].Size)
}
} else {
fmt.Println(d)
}
}

It gives error undefined: ioutil.Stat. Which is weird since if
ioutil.Stat was undefined the compiler should also have raised error
package io/ioutil declared and not used. I tried all sorts of
combination described in package like using a alias or just a dot(.)
but none seemed to work.
I want to know why ?

regards,
Soham

Kevin Ballard

unread,
Mar 23, 2010, 10:18:00 PM3/23/10
to Soham, golang-nuts
The error is the Stat function belongs to the os package, not the
ioutil package.

-Kevin Ballard

> To unsubscribe from this group, send email to golang-nuts+unsubscribegooglegroups.com or reply to this email with the words "REMOVE ME" as the subject.
>

--
Kevin Ballard
http://kevin.sb.org
kbal...@gmail.com

Soham

unread,
Mar 24, 2010, 12:02:31 AM3/24/10
to golang-nuts
yucks, I must be day dreaming.

thanks a million :) kevin.

Soham

> kball...@gmail.com

Reply all
Reply to author
Forward
0 new messages