not enough arguments in call to strings.Split

899 views
Skip to first unread message

Mike

unread,
Aug 10, 2011, 6:22:41 AM8/10/11
to golan...@googlegroups.com
Could You explain following behavior:

A) I compile the following locally with my 8g version release.r59 9022 and it works. Output: [A,B,C]
     package main
 
     import "fmt"
     import "strings"
      
     func main() {
        var x = "A|B|C"
        fmt.Println(strings.Split(x, "|"))
     }

B) When I compile & run the same code on the Go Playground it says: "not enough arguments in call to strings.Split.
C) I get the same error when using strings.Split that way in Google App 'Engine and compile it with dev_appserver.py ...

It works in variant B) and C) when modifying above code into strings.Split(x, "|" , 1). But then it doesn't work in variant A, where I get the error "too many arguments in call to strings.Split.

The package description says:
func Split(s, sep string) []string

BR



 

 

peterGo

unread,
Aug 10, 2011, 6:44:09 AM8/10/11
to golang-nuts
Mike,

On Go Playground, run:

package main

import ("fmt";"runtime")

func main() {
fmt.Println(runtime.Version())
}

Output:

release.r57.2 8306+

Lokk at the release notes for release. r59, which include a change to
Split that is not included in release.r57.2 8306+.

Package strings's Split function has itself been split into Split and
SplitN. SplitN is the same as the old Split. The new Split is
equivalent to SplitN with a final argument of -1.
http://golang.org/doc/devel/release.html#r59

Peter

Mike

unread,
Aug 10, 2011, 8:13:15 AM8/10/11
to golan...@googlegroups.com
Peter, tx. I use the "old" Split with final argument -1. Then it works on App Engine.

P.S.: App Engine's dev_appserver.py seems to run with release.r58.1 8739 at moment.

David Symonds

unread,
Aug 11, 2011, 7:21:56 AM8/11/11
to peterGo, golang-nuts
The playground is now running on release.r59. Sorry for the delay.


Dave.

Reply all
Reply to author
Forward
0 new messages