Skip to content

Commit

Permalink
Change NewSmartViewSession signature
Browse files Browse the repository at this point in the history
The function should not return acopy of the SmartViewSession struct,
since it contains a Mutex.
(Thanks to go vet.)
  • Loading branch information
McKael committed Apr 22, 2019
1 parent 39795ea commit c3c718f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ func initSession() (*samtv.SmartViewSession, error) {
s.RestoreSessionData(sessionKey, smartSessionID, smartDeviceID)

err = s.InitSession()
return &s, err
return s, err
}
8 changes: 4 additions & 4 deletions samtv.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ const (
const defaultSessionUUID = "samtv"

// NewSmartViewSession initializes en new SmartViewSession
func NewSmartViewSession(tvAddress string) (SmartViewSession, error) {
func NewSmartViewSession(tvAddress string) (*SmartViewSession, error) {

if tvAddress == "" {
return SmartViewSession{}, errors.New("empty TV IP address")
return nil, errors.New("empty TV IP address")
}

// Basic check
if strings.ContainsRune(tvAddress, ':') {
return SmartViewSession{}, errors.New("the address should not contain a semicolon")
return nil, errors.New("the address should not contain a semicolon")
}

svs := SmartViewSession{
Expand All @@ -77,7 +77,7 @@ func NewSmartViewSession(tvAddress string) (SmartViewSession, error) {

svs.ws.read = make(chan string, 16)

return svs, nil
return &svs, nil
}

// RestoreSessionData sets SmartViewSession key, ID and UUID values
Expand Down

0 comments on commit c3c718f

Please sign in to comment.