I am trying to compile the following function:
func (self algo_t) chk_args(args []string) {
if args.len() != self.num_args {
fmt.Fprintf(
os.Stdout,
"%s expected %d argument(s), received %d
",
self.name,
self.num_args,
args.len(),
)
fmt.Printf("quickcrypt %s
", self.usage)
}
}
I am receiving the error, args.len undefined (type []string has no field or method len)
.
Args is of type []string
, and the language specification says this is a slice type. The builtin
package documentation says v.len()
is defined for Slice types. What is going on?