util

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0, BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

* * Copyright 2021 Comcast Cable Communications Management, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * SPDX-License-Identifier: Apache-2.0

Index

Constants

View Source
const (
	Comma              = ','
	RightSquareBracket = ']'
	RightCurlBracket   = '}'
)

Variables

This section is empty.

Functions

func AppendProfiles added in v1.0.0

func AppendProfiles(pbytes, sbytes []byte) ([]byte, error)

func BuildHttp added in v1.0.0

func BuildHttp(header http.Header, bbytes []byte) []byte

func CaseInsensitiveContains

func CaseInsensitiveContains(data []string, x string) bool

func CompactJson added in v1.0.0

func CompactJson(sbytes []byte) ([]byte, error)

func Contains

func Contains(collection interface{}, element interface{}) bool

func ContainsInt

func ContainsInt(data []int, x int) bool

TODO keep it for backward compatibility in "webconfig" for now

plan to remove it later

func FieldsGetString added in v1.0.0

func FieldsGetString(fields log.Fields, keyName string, args ...string) string

func GenerateRandomCpeMac

func GenerateRandomCpeMac() string

func GetAPIName added in v1.0.0

func GetAPIName(queryStr string) string

func GetAuditId

func GetAuditId() string

func GetEstbMacAddress added in v1.0.0

func GetEstbMacAddress(mac string) string

func GetMacDiff added in v1.0.0

func GetMacDiff(wanMac, mac string) int

func GetMockMultiparts added in v1.0.0

func GetMockMultiparts(queryStr string) []common.Multipart

func GetMurmur3Hash

func GetMurmur3Hash(payload []byte) string

func GetMurmur3HashByTwmb

func GetMurmur3HashByTwmb(payload []byte) string

my benchmark test showed this is better by a small margin

func GetRandomRootVersion added in v1.0.0

func GetRandomRootVersion() string

func GetTelemetryQueryString added in v1.0.0

func GetTelemetryQueryString(header http.Header, mac, queryParams, partnerId string) string

func HeaderToMap added in v1.0.0

func HeaderToMap(header http.Header) map[string]string

func IsValidUTF8 added in v1.0.0

func IsValidUTF8(bbytes []byte) bool

func ParseHttp added in v1.0.0

func ParseHttp(bbytes []byte) (http.Header, []byte)

func ParseMultipart

func ParseMultipart(header http.Header, bbytes []byte) (map[string]common.Multipart, error)

func ParseMultipartAsList

func ParseMultipartAsList(header http.Header, bbytes []byte) ([]common.Multipart, error)

func PrettyJson

func PrettyJson(input interface{}) string

func TelemetryBytesToMultipart added in v1.0.0

func TelemetryBytesToMultipart(telemetryBytes []byte) (common.Multipart, error)

func ToColonMac

func ToColonMac(d string) string

func ToInt

func ToInt(itf interface{}) int

func ValidateMac

func ValidateMac(mac string) bool

func ValidatePokeQuery added in v1.0.0

func ValidatePokeQuery(values url.Values) (string, error)

func ValidateQueryParams added in v1.0.0

func ValidateQueryParams(r *http.Request, validSubdocIdMap map[string]int, fields log.Fields) error

Types

type Dict

type Dict map[string]interface{}

func ParseMultipartsForLogging added in v1.0.0

func ParseMultipartsForLogging(rbytes []byte, header http.Header, subdocIds []string) (Dict, error)

func (Dict) Copy

func (d Dict) Copy() Dict

func (Dict) GetBool added in v1.0.0

func (d Dict) GetBool(key string, defaults ...bool) bool

func (Dict) GetInt added in v1.0.0

func (d Dict) GetInt(key string, defaults ...int) int

func (Dict) GetNonEmptyString added in v1.0.0

func (d Dict) GetNonEmptyString(key string, defaults ...string) string

func (Dict) GetString added in v1.0.0

func (d Dict) GetString(key string, defaults ...string) string

func (Dict) MsecsToTime

func (d Dict) MsecsToTime(fields ...string)

func (Dict) SelectByKeys

func (d Dict) SelectByKeys(names ...string) Dict

func (Dict) String

func (d Dict) String() string

func (Dict) TimeToMsecs

func (d Dict) TimeToMsecs(field string)

func (Dict) ToInt

func (d Dict) ToInt(fields ...string)

func (Dict) ToInt64

func (d Dict) ToInt64(fields ...string)

func (Dict) Update added in v1.0.0

func (d Dict) Update(itf interface{})

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址