github.com/adacta-ru/mattermost-server/v6@v6.0.0/app/plugin_api_tests/basic_config.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package plugin_api_tests
     5  
     6  import "reflect"
     7  
     8  type BasicConfig struct {
     9  	BasicChannelId       string
    10  	BasicChannelName     string
    11  	BasicPostId          string
    12  	BasicPostMessage     string
    13  	BasicTeamDisplayName string
    14  	BasicTeamId          string
    15  	BasicTeamName        string
    16  	BasicUser2Email      string
    17  	BasicUser2Id         string
    18  	BasicUserEmail       string
    19  	BasicUserId          string
    20  }
    21  
    22  func IsEmpty(object interface{}) bool {
    23  
    24  	// get nil case out of the way
    25  	if object == nil {
    26  		return true
    27  	}
    28  
    29  	objValue := reflect.ValueOf(object)
    30  
    31  	switch objValue.Kind() {
    32  	// collection types are empty when they have no element
    33  	case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice:
    34  		return objValue.Len() == 0
    35  	// pointers are empty if nil or if the value they point to is empty
    36  	case reflect.Ptr:
    37  		if objValue.IsNil() {
    38  			return true
    39  		}
    40  		deref := objValue.Elem().Interface()
    41  		return IsEmpty(deref)
    42  	// for all other types, compare against the zero value
    43  	default:
    44  		zero := reflect.Zero(objValue.Type())
    45  		return reflect.DeepEqual(object, zero.Interface())
    46  	}
    47  }