You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by ha...@apache.org on 2022/12/13 03:17:01 UTC

[iotdb-client-go] branch main updated: set DefaultTimeZone if GetTimeZone returns an error (#69)

This is an automated email from the ASF dual-hosted git repository.

haonan pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/iotdb-client-go.git


The following commit(s) were added to refs/heads/main by this push:
     new c08655b  set DefaultTimeZone if GetTimeZone returns an error (#69)
c08655b is described below

commit c08655b8d68f7b2539f22dd8c604ee4d332daab6
Author: 橘子 <70...@users.noreply.github.com>
AuthorDate: Mon Dec 12 19:16:57 2022 -0800

    set DefaultTimeZone if GetTimeZone returns an error (#69)
    
    1. If the error is not handled, the TimeZone in the config may be directly set to a empty string value
    2. In previous file 'session_example.go', the time zone was printed only when there was an error. It should be a logical error
---
 client/session.go          | 2 +-
 example/session_example.go | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/client/session.go b/client/session.go
index 91bfea1..84c6ac5 100644
--- a/client/session.go
+++ b/client/session.go
@@ -406,7 +406,7 @@ func (s *Session) InsertStringRecord(deviceId string, measurements []string, val
 func (s *Session) GetTimeZone() (string, error) {
 	resp, err := s.client.GetTimeZone(context.Background(), s.sessionId)
 	if err != nil {
-		return "", err
+		return DefaultTimeZone, err
 	}
 	return resp.TimeZone, nil
 }
diff --git a/example/session_example.go b/example/session_example.go
index 6af3cb9..ce6a043 100644
--- a/example/session_example.go
+++ b/example/session_example.go
@@ -102,8 +102,10 @@ func main() {
 	deleteData()
 
 	setTimeZone()
-	if tz, err := getTimeZone(); err != nil {
-		fmt.Printf("TimeZone: %s", tz)
+	if tz, err := getTimeZone(); err == nil {
+		fmt.Printf("TimeZone: %s\n", tz)
+	} else {
+		fmt.Printf("getTimeZone ERROR: %v\n", err)
 	}
 
 	executeStatement()