* replace interface{} with any
Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-07-05 09:46:50 +03:00
коммит произвёл GitHub
родитель b45ff0be5d
Коммит 717a4d04a9
258 изменённых файлов: 1286 добавлений и 1286 удалений

Просмотреть файл

@@ -152,15 +152,15 @@ func (p *precomputedWebSocketEventJSON) copy() *precomputedWebSocketEventJSON {
// webSocketEventJSON mirrors WebSocketEvent to make some of its unexported fields serializable
type webSocketEventJSON struct {
Event string `json:"event"`
Data map[string]interface{} `json:"data"`
Broadcast *WebsocketBroadcast `json:"broadcast"`
Sequence int64 `json:"seq"`
Event string `json:"event"`
Data map[string]any `json:"data"`
Broadcast *WebsocketBroadcast `json:"broadcast"`
Sequence int64 `json:"seq"`
}
type WebSocketEvent struct {
event string
data map[string]interface{}
data map[string]any
broadcast *WebsocketBroadcast
sequence int64
precomputedJSON *precomputedWebSocketEventJSON
@@ -181,14 +181,14 @@ func (ev *WebSocketEvent) PrecomputeJSON() *WebSocketEvent {
return copy
}
func (ev *WebSocketEvent) Add(key string, value interface{}) {
func (ev *WebSocketEvent) Add(key string, value any) {
ev.data[key] = value
}
func NewWebSocketEvent(event, teamId, channelId, userId string, omitUsers map[string]bool) *WebSocketEvent {
return &WebSocketEvent{
event: event,
data: make(map[string]interface{}),
data: make(map[string]any),
broadcast: &WebsocketBroadcast{
TeamId: teamId,
ChannelId: channelId,
@@ -209,9 +209,9 @@ func (ev *WebSocketEvent) Copy() *WebSocketEvent {
}
func (ev *WebSocketEvent) DeepCopy() *WebSocketEvent {
var dataCopy map[string]interface{}
var dataCopy map[string]any
if ev.data != nil {
dataCopy = make(map[string]interface{}, len(ev.data))
dataCopy = make(map[string]any, len(ev.data))
for k, v := range ev.data {
dataCopy[k] = v
}
@@ -227,7 +227,7 @@ func (ev *WebSocketEvent) DeepCopy() *WebSocketEvent {
return copy
}
func (ev *WebSocketEvent) GetData() map[string]interface{} {
func (ev *WebSocketEvent) GetData() map[string]any {
return ev.data
}
@@ -245,7 +245,7 @@ func (ev *WebSocketEvent) SetEvent(event string) *WebSocketEvent {
return copy
}
func (ev *WebSocketEvent) SetData(data map[string]interface{}) *WebSocketEvent {
func (ev *WebSocketEvent) SetData(data map[string]any) *WebSocketEvent {
copy := ev.Copy()
copy.data = data
return copy
@@ -308,7 +308,7 @@ func WebSocketEventFromJSON(data io.Reader) (*WebSocketEvent, error) {
ev.event = o.Event
if u, ok := o.Data["user"]; ok {
// We need to convert to and from JSON again
// because the user is in the form of a map[string]interface{}.
// because the user is in the form of a map[string]any.
buf, err := json.Marshal(u)
if err != nil {
return nil, err
@@ -330,17 +330,17 @@ func WebSocketEventFromJSON(data io.Reader) (*WebSocketEvent, error) {
// for a request made to the server. This is available through the ResponseChannel
// channel in WebSocketClient.
type WebSocketResponse struct {
Status string `json:"status"` // The status of the response. For example: OK, FAIL.
SeqReply int64 `json:"seq_reply,omitempty"` // A counter which is incremented for every response sent.
Data map[string]interface{} `json:"data,omitempty"` // The data contained in the response.
Error *AppError `json:"error,omitempty"` // A field that is set if any error has occurred.
Status string `json:"status"` // The status of the response. For example: OK, FAIL.
SeqReply int64 `json:"seq_reply,omitempty"` // A counter which is incremented for every response sent.
Data map[string]any `json:"data,omitempty"` // The data contained in the response.
Error *AppError `json:"error,omitempty"` // A field that is set if any error has occurred.
}
func (m *WebSocketResponse) Add(key string, value interface{}) {
func (m *WebSocketResponse) Add(key string, value any) {
m.Data[key] = value
}
func NewWebSocketResponse(status string, seqReply int64, data map[string]interface{}) *WebSocketResponse {
func NewWebSocketResponse(status string, seqReply int64, data map[string]any) *WebSocketResponse {
return &WebSocketResponse{Status: status, SeqReply: seqReply, Data: data}
}