From efe1bacf3dbba9df3d2ad66c7ae9bf88bef34c7e Mon Sep 17 00:00:00 2001
From: Christoph Glaubitz <christoph.glaubitz@innovo-cloud.de>
Date: Fri, 9 Jun 2017 14:26:18 +0200
Subject: [PATCH] Resolved pending comments

* typos
* more of error checking
* removed unneded code
* changed Code generated comment
* removed generation timestamp, we have a version control ;)
---
 netbox/generate_basic_tests.go             | 10 +++++-----
 netbox/generate_functions.go               | 18 ++++++++++--------
 netbox/tenancy.go                          |  2 +-
 netbox/tenancy_tenant-groups.go            | 12 ++++++------
 netbox/tenancy_tenant-groups_basic_test.go |  4 +---
 netbox/tenancy_tenants.go                  | 12 ++++++------
 netbox/tenancy_tenants_basic_test.go       |  4 +---
 7 files changed, 30 insertions(+), 32 deletions(-)

diff --git a/netbox/generate_basic_tests.go b/netbox/generate_basic_tests.go
index 01d83e7..446e712 100644
--- a/netbox/generate_basic_tests.go
+++ b/netbox/generate_basic_tests.go
@@ -64,7 +64,6 @@ func main() {
 	// go fmt
 	res, err := format.Source(b.Bytes())
 	if err != nil {
-		b.WriteTo(os.Stderr)
 		log.Fatal(err)
 	}
 
@@ -73,7 +72,10 @@ func main() {
 		log.Fatal(err)
 	}
 	defer f.Close()
-	f.Write(res)
+	_, err = f.Write(res)
+	if err != nil {
+		log.Fatal(err)
+	}
 }
 
 var functionsTemplate = template.Must(template.New("").Parse(`// Copyright 2017 The go-netbox Authors.
@@ -90,9 +92,7 @@ var functionsTemplate = template.Must(template.New("").Parse(`// Copyright 2017
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-// This file was generated by robots at
-// {{ .Timestamp }}
+// Code generated by generate_functions.go. DO NOT EDIT.
 
 package netbox
 
diff --git a/netbox/generate_functions.go b/netbox/generate_functions.go
index de6f33a..9411f8c 100644
--- a/netbox/generate_functions.go
+++ b/netbox/generate_functions.go
@@ -63,7 +63,6 @@ func main() {
 	// go fmt
 	res, err := format.Source(b.Bytes())
 	if err != nil {
-		b.WriteTo(os.Stderr)
 		log.Fatal(err)
 	}
 
@@ -72,7 +71,10 @@ func main() {
 		log.Fatal(err)
 	}
 	defer f.Close()
-	f.Write(res)
+	_, err = f.Write(res)
+	if err != nil {
+		log.Fatal(err)
+	}
 }
 
 var functionsTemplate = template.Must(template.New("").Parse(`// Copyright 2017 The go-netbox Authors.
@@ -89,9 +91,7 @@ var functionsTemplate = template.Must(template.New("").Parse(`// Copyright 2017
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-// This file was generated by robots at
-// {{ .Timestamp }}
+// Code generated by generate_functions.go. DO NOT EDIT.
 
 package netbox
 
@@ -170,14 +170,15 @@ func (s *{{ .ServiceName }}) Update(data *{{ .TypeName }}) (int, error) {
 		http.MethodPatch,
 		fmt.Sprintf("api/{{ .Endpoint }}/{{ .Service }}/%d/", data.ID),
 		nil,
-		data)
+		data,
+	)
 	if err != nil {
 		return 0, err
 	}
 
 	// g is just used to verify correct api result.
 	// data is not changed, because the g is not the full representation that one would
-	// get with Get. But if the response was unmarshaled into {{ .UpdateTypeName }} corretcly,
+	// get with Get. But if the response was unmarshaled into {{ .UpdateTypeName }} correctly,
 	// everything went fine, and we do not need to update data.
 	g := new({{ .UpdateTypeName }})
 	err = s.c.Do(req, g)
@@ -192,7 +193,8 @@ func (s *{{ .ServiceName }}) Delete(data *{{ .TypeName }}) error {
 	req, err := s.c.NewRequest(
 		http.MethodDelete,
 		fmt.Sprintf("api/{{ .Endpoint }}/{{ .Service }}/%d/", data.ID),
-		nil)
+		nil,
+	)
 	if err != nil {
 		return err
 	}
diff --git a/netbox/tenancy.go b/netbox/tenancy.go
index e88eb63..b44124f 100644
--- a/netbox/tenancy.go
+++ b/netbox/tenancy.go
@@ -21,7 +21,7 @@ type TenancyService struct {
 	Tenants      *TenantsService
 }
 
-// NewTenancyService returns a TenancyService initialized with all sub-service.
+// NewTenancyService returns a TenancyService initialized with all sub-services.
 func NewTenancyService(client *Client) *TenancyService {
 	return &TenancyService{
 		c: client,
diff --git a/netbox/tenancy_tenant-groups.go b/netbox/tenancy_tenant-groups.go
index a774fae..8e1a62a 100644
--- a/netbox/tenancy_tenant-groups.go
+++ b/netbox/tenancy_tenant-groups.go
@@ -12,9 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-// This file was generated by robots at
-// 2017-05-18 14:20:17.056969293 +0200 CEST
+// Code generated by generate_functions.go. DO NOT EDIT.
 
 package netbox
 
@@ -87,14 +85,15 @@ func (s *TenantGroupsService) Update(data *TenantGroup) (int, error) {
 		http.MethodPatch,
 		fmt.Sprintf("api/tenancy/tenant-groups/%d/", data.ID),
 		nil,
-		data)
+		data,
+	)
 	if err != nil {
 		return 0, err
 	}
 
 	// g is just used to verify correct api result.
 	// data is not changed, because the g is not the full representation that one would
-	// get with Get. But if the response was unmarshaled into TenantGroup corretcly,
+	// get with Get. But if the response was unmarshaled into TenantGroup correctly,
 	// everything went fine, and we do not need to update data.
 	g := new(TenantGroup)
 	err = s.c.Do(req, g)
@@ -109,7 +108,8 @@ func (s *TenantGroupsService) Delete(data *TenantGroup) error {
 	req, err := s.c.NewRequest(
 		http.MethodDelete,
 		fmt.Sprintf("api/tenancy/tenant-groups/%d/", data.ID),
-		nil)
+		nil,
+	)
 	if err != nil {
 		return err
 	}
diff --git a/netbox/tenancy_tenant-groups_basic_test.go b/netbox/tenancy_tenant-groups_basic_test.go
index b96098d..2e3322e 100644
--- a/netbox/tenancy_tenant-groups_basic_test.go
+++ b/netbox/tenancy_tenant-groups_basic_test.go
@@ -12,9 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-// This file was generated by robots at
-// 2017-05-18 14:20:17.307177904 +0200 CEST
+// Code generated by generate_functions.go. DO NOT EDIT.
 
 package netbox
 
diff --git a/netbox/tenancy_tenants.go b/netbox/tenancy_tenants.go
index 5b751de..0c265ac 100644
--- a/netbox/tenancy_tenants.go
+++ b/netbox/tenancy_tenants.go
@@ -12,9 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-// This file was generated by robots at
-// 2017-05-18 14:20:17.557582817 +0200 CEST
+// Code generated by generate_functions.go. DO NOT EDIT.
 
 package netbox
 
@@ -87,14 +85,15 @@ func (s *TenantsService) Update(data *Tenant) (int, error) {
 		http.MethodPatch,
 		fmt.Sprintf("api/tenancy/tenants/%d/", data.ID),
 		nil,
-		data)
+		data,
+	)
 	if err != nil {
 		return 0, err
 	}
 
 	// g is just used to verify correct api result.
 	// data is not changed, because the g is not the full representation that one would
-	// get with Get. But if the response was unmarshaled into updateTenant corretcly,
+	// get with Get. But if the response was unmarshaled into updateTenant correctly,
 	// everything went fine, and we do not need to update data.
 	g := new(updateTenant)
 	err = s.c.Do(req, g)
@@ -109,7 +108,8 @@ func (s *TenantsService) Delete(data *Tenant) error {
 	req, err := s.c.NewRequest(
 		http.MethodDelete,
 		fmt.Sprintf("api/tenancy/tenants/%d/", data.ID),
-		nil)
+		nil,
+	)
 	if err != nil {
 		return err
 	}
diff --git a/netbox/tenancy_tenants_basic_test.go b/netbox/tenancy_tenants_basic_test.go
index 6586429..e26756f 100644
--- a/netbox/tenancy_tenants_basic_test.go
+++ b/netbox/tenancy_tenants_basic_test.go
@@ -12,9 +12,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-// GENERATED BY THE COMMAND ABOVE; DO NOT EDIT
-// This file was generated by robots at
-// 2017-05-18 14:20:17.805444662 +0200 CEST
+// Code generated by generate_functions.go. DO NOT EDIT.
 
 package netbox
 
-- 
GitLab