github.com/haalcala/mattermost-server-change-repo@v0.0.0-20210713015153-16753fbeee5f/plugin/stringifier.go (about)

     1  // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
     2  // See LICENSE.txt for license information.
     3  
     4  package plugin
     5  
     6  import (
     7  	"fmt"
     8  )
     9  
    10  func stringify(objects []interface{}) []string {
    11  	stringified := make([]string, len(objects))
    12  	for i, object := range objects {
    13  		stringified[i] = fmt.Sprintf("%+v", object)
    14  	}
    15  	return stringified
    16  }
    17  
    18  func toObjects(strings []string) []interface{} {
    19  	if strings == nil {
    20  		return nil
    21  	}
    22  	objects := make([]interface{}, len(strings))
    23  	for i, string := range strings {
    24  		objects[i] = string
    25  	}
    26  	return objects
    27  }
    28  
    29  func stringifyToObjects(objects []interface{}) []interface{} {
    30  	return toObjects(stringify(objects))
    31  }