Skip to content

Commit c08655b

Browse files
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
1 parent 5d806c5 commit c08655b

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

client/session.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ func (s *Session) InsertStringRecord(deviceId string, measurements []string, val
406406
func (s *Session) GetTimeZone() (string, error) {
407407
resp, err := s.client.GetTimeZone(context.Background(), s.sessionId)
408408
if err != nil {
409-
return "", err
409+
return DefaultTimeZone, err
410410
}
411411
return resp.TimeZone, nil
412412
}

example/session_example.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,10 @@ func main() {
102102
deleteData()
103103

104104
setTimeZone()
105-
if tz, err := getTimeZone(); err != nil {
106-
fmt.Printf("TimeZone: %s", tz)
105+
if tz, err := getTimeZone(); err == nil {
106+
fmt.Printf("TimeZone: %s\n", tz)
107+
} else {
108+
fmt.Printf("getTimeZone ERROR: %v\n", err)
107109
}
108110

109111
executeStatement()

0 commit comments

Comments
 (0)