{"action":"created","issue":{"url":"https://api.github.com/repos/rackspace/gophercloud/issues/370","labels_url":"https://api.github.com/repos/rackspace/gophercloud/issues/370/labels{/name}","comments_url":"https://api.github.com/repos/rackspace/gophercloud/issues/370/comments","events_url":"https://api.github.com/repos/rackspace/gophercloud/issues/370/events","html_url":"https://github.com/rackspace/gophercloud/issues/370","id":57647517,"number":370,"title":"Invalid memory address or nil pointer dereference in ServiceClient","user":{"login":"maxlinc","id":896878,"avatar_url":"https://avatars.githubusercontent.com/u/896878?v=3","gravatar_id":"","url":"https://api.github.com/users/maxlinc","html_url":"https://github.com/maxlinc","followers_url":"https://api.github.com/users/maxlinc/followers","following_url":"https://api.github.com/users/maxlinc/following{/other_user}","gists_url":"https://api.github.com/users/maxlinc/gists{/gist_id}","starred_url":"https://api.github.com/users/maxlinc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxlinc/subscriptions","organizations_url":"https://api.github.com/users/maxlinc/orgs","repos_url":"https://api.github.com/users/maxlinc/repos","events_url":"https://api.github.com/users/maxlinc/events{/privacy}","received_events_url":"https://api.github.com/users/maxlinc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-02-13T20:08:03Z","updated_at":"2015-02-13T20:33:55Z","closed_at":null,"body":"I'm getting an error while trying to test an example based on the [Create Network documentation](http://gophercloud.io/docs/networking/#create-network). There's a good chance my code is wrong but @smashwilson took a quick look and said it looked okay at first glance.\r\n\r\nMy code:\r\n```go\r\npackage main\r\n\r\nimport (\r\n  \"fmt\"\r\n  \"os\"\r\n  \"github.com/rackspace/gophercloud\"\r\n  \"github.com/rackspace/gophercloud/rackspace\"\r\n  \"github.com/rackspace/gophercloud/openstack/networking/v2/networks\"\r\n)\r\n\r\nfunc main() {\r\n  ao := gophercloud.AuthOptions{\r\n    IdentityEndpoint: os.Getenv(\"OS_AUTH_URL\"),\r\n    Username: os.Getenv(\"RAX_USERNAME\"),\r\n    APIKey:   os.Getenv(\"RAX_API_KEY\"),\r\n  }\r\n  provider, err := rackspace.AuthenticatedClient(ao)\r\n  if err != nil {\r\n    panic(err)\r\n  }\r\n\r\n  client, err := rackspace.NewNetworkV2(provider, gophercloud.EndpointOpts{\r\n    Name:   \"neutron\",\r\n    Region: os.Getenv(\"RAX_REGION\"),\r\n  })\r\n\r\n  // We specify a name and that it should forward packets\r\n  opts := networks.CreateOpts{Name: \"main_network\", AdminStateUp: networks.Up}\r\n\r\n  // Execute the operation and get back a networks.Network struct\r\n  network, err := networks.Create(client, opts).Extract()\r\n  fmt.Printf(\"Created network: %v (%v)\", network.Name, network.ID)\r\n}\r\n```\r\n\r\nThe error:\r\n```\r\n$ go run src/github.com/maxlinc/gophercloud-examples/network/create_network.go\r\npanic: runtime error: invalid memory address or nil pointer dereference\r\n[signal 0xb code=0x1 addr=0x20 pc=0x393ec]\r\n\r\ngoroutine 1 [running]:\r\ngithub.com/rackspace/gophercloud.(*ServiceClient).ServiceURL(0x0, 0x491b28, 0x1, 0x1, 0xc2000e3f60, ...)\r\n\t/Users/Thoughtworker/go/src/github.com/rackspace/gophercloud/service_client.go:31 +0x1c\r\ngithub.com/rackspace/gophercloud/openstack/networking/v2/networks.rootURL(0x0, 0x0, 0x0)\r\n\t/Users/Thoughtworker/go/src/github.com/rackspace/gophercloud/openstack/networking/v2/networks/urls.go:10 +0x7b\r\ngithub.com/rackspace/gophercloud/openstack/networking/v2/networks.createURL(0x0, 0xc200395d00, 0x0)\r\n\t/Users/Thoughtworker/go/src/github.com/rackspace/gophercloud/openstack/networking/v2/networks/urls.go:22 +0x25\r\ngithub.com/rackspace/gophercloud/openstack/networking/v2/networks.Create(0x0, 0xc2000e3ea0, 0xc2000e3ed0, 0x380121, 0x253c30, ...)\r\n\t/Users/Thoughtworker/go/src/github.com/rackspace/gophercloud/openstack/networking/v2/networks/requests.go:141 +0xd6\r\nmain.main()\r\n\t/Users/Thoughtworker/repos/rackspace/polytrix-openstack/sdks/gophercloud/src/github.com/maxlinc/gophercloud-examples/network/create_network.go:31 +0x2a9\r\n\r\ngoroutine 2 [syscall]:\r\n\r\ngoroutine 5 [runnable]:\r\nnet/http.(*persistConn).readLoop(0xc2000c0180)\r\n\t/usr/local/go/src/pkg/net/http/transport.go:761 +0x64b\r\ncreated by net/http.(*Transport).dialConn\r\n\t/usr/local/go/src/pkg/net/http/transport.go:511 +0x574\r\n\r\ngoroutine 6 [select]:\r\nnet/http.(*persistConn).writeLoop(0xc2000c0180)\r\n\t/usr/local/go/src/pkg/net/http/transport.go:774 +0x26f\r\ncreated by net/http.(*Transport).dialConn\r\n\t/usr/local/go/src/pkg/net/http/transport.go:512 +0x58b\r\nexit status 2\r\n```\r\n\r\nI thought the value of region might have been the issue, but I've tested with ORD, IAD, DFW and dfw without any luck."},"comment":{"url":"https://api.github.com/repos/rackspace/gophercloud/issues/comments/74322190","html_url":"https://github.com/rackspace/gophercloud/issues/370#issuecomment-74322190","issue_url":"https://api.github.com/repos/rackspace/gophercloud/issues/370","id":74322190,"user":{"login":"jrperritt","id":1733222,"avatar_url":"https://avatars.githubusercontent.com/u/1733222?v=3","gravatar_id":"","url":"https://api.github.com/users/jrperritt","html_url":"https://github.com/jrperritt","followers_url":"https://api.github.com/users/jrperritt/followers","following_url":"https://api.github.com/users/jrperritt/following{/other_user}","gists_url":"https://api.github.com/users/jrperritt/gists{/gist_id}","starred_url":"https://api.github.com/users/jrperritt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrperritt/subscriptions","organizations_url":"https://api.github.com/users/jrperritt/orgs","repos_url":"https://api.github.com/users/jrperritt/repos","events_url":"https://api.github.com/users/jrperritt/events{/privacy}","received_events_url":"https://api.github.com/users/jrperritt/received_events","type":"User","site_admin":false},"created_at":"2015-02-13T20:33:55Z","updated_at":"2015-02-13T20:33:55Z","body":"To be more specific, you're getting that error because you're not checking for an error after you try creating the `NewNetworkV2` client. Checking that error should show you that there isn't an endpoint in the service catalog for the options you provided."}}