diff --git a/agents/kamagent.go b/agents/kamagent.go
index c6ee74925..0d21964b3 100644
--- a/agents/kamagent.go
+++ b/agents/kamagent.go
@@ -246,7 +246,7 @@ func (ka *KamailioAgent) onCallEnd(evData []byte, connIdx int) {
utils.KamailioAgent, kev[utils.OriginID], err.Error()))
// no return here since we want CDR anyhow
}
- if ka.cfg.CreateCdr || strings.Index(kev[utils.CGRFlags], utils.MetaCDRs) != -1 {
+ if ka.cfg.CreateCdr || strings.Contains(kev[utils.CGRFlags], utils.MetaCDRs) {
if err := ka.connMgr.Call(ka.ctx, ka.cfg.SessionSConns,
utils.SessionSv1ProcessCDR,
tsArgs.CGREvent, &reply); err != nil {
diff --git a/agents/libdns.go b/agents/libdns.go
index 8481a2bc6..66eaf1946 100644
--- a/agents/libdns.go
+++ b/agents/libdns.go
@@ -34,9 +34,7 @@ func newDnsReply(req *dns.Msg) (rply *dns.Msg) {
rply.SetReply(req)
if len(req.Question) > 0 {
rply.Question = make([]dns.Question, len(req.Question))
- for i, q := range req.Question {
- rply.Question[i] = q
- }
+ copy(rply.Question, req.Question)
}
if opts := rply.IsEdns0(); opts != nil {
rply.SetEdns0(4096, false).IsEdns0().Option = opts.Option
diff --git a/apier/v1/filter_indexes.go b/apier/v1/filter_indexes.go
index 4115ee8c5..095fb05c3 100644
--- a/apier/v1/filter_indexes.go
+++ b/apier/v1/filter_indexes.go
@@ -151,7 +151,7 @@ func (apierSv1 *APIerSv1) GetFilterIndexes(ctx *context.Context, arg *AttrGetFil
if len(indexedSlice) == 0 {
indexesFilter = make(map[string]utils.StringSet)
for val, strmap := range indexes {
- if strings.Index(val, arg.FilterField) != -1 {
+ if strings.Contains(val, arg.FilterField) {
indexesFilter[val] = strmap
for _, value := range strmap.AsSlice() {
indexedSlice = append(indexedSlice, utils.ConcatenatedKey(val, value))
@@ -164,7 +164,7 @@ func (apierSv1 *APIerSv1) GetFilterIndexes(ctx *context.Context, arg *AttrGetFil
} else {
var cloneIndexSlice []string
for val, strmap := range indexesFilter {
- if strings.Index(val, arg.FilterField) != -1 {
+ if strings.Contains(val, arg.FilterField) {
for _, value := range strmap.AsSlice() {
cloneIndexSlice = append(cloneIndexSlice, utils.ConcatenatedKey(val, value))
}
@@ -179,7 +179,7 @@ func (apierSv1 *APIerSv1) GetFilterIndexes(ctx *context.Context, arg *AttrGetFil
if arg.FilterValue != utils.EmptyString {
if len(indexedSlice) == 0 {
for val, strmap := range indexes {
- if strings.Index(val, arg.FilterValue) != -1 {
+ if strings.Contains(val, arg.FilterValue) {
for _, value := range strmap.AsSlice() {
indexedSlice = append(indexedSlice, utils.ConcatenatedKey(val, value))
}
@@ -191,7 +191,7 @@ func (apierSv1 *APIerSv1) GetFilterIndexes(ctx *context.Context, arg *AttrGetFil
} else {
var cloneIndexSlice []string
for val, strmap := range indexesFilter {
- if strings.Index(val, arg.FilterValue) != -1 {
+ if strings.Contains(val, arg.FilterValue) {
for _, value := range strmap.AsSlice() {
cloneIndexSlice = append(cloneIndexSlice, utils.ConcatenatedKey(val, value))
}
@@ -238,9 +238,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(ctx *context.Context, args *utils
return nil, e
}
fltrIDs := make([]string, len(th.FilterIDs))
- for i, fltrID := range th.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, th.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -257,9 +255,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(ctx *context.Context, args *utils
return nil, e
}
fltrIDs := make([]string, len(sq.FilterIDs))
- for i, fltrID := range sq.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, sq.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -276,9 +272,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(ctx *context.Context, args *utils
return nil, e
}
fltrIDs := make([]string, len(rp.FilterIDs))
- for i, fltrID := range rp.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, rp.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -295,9 +289,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(ctx *context.Context, args *utils
return nil, e
}
fltrIDs := make([]string, len(rp.FilterIDs))
- for i, fltrID := range rp.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, rp.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -317,9 +309,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(ctx *context.Context, args *utils
return nil, nil
}
fltrIDs := make([]string, len(ap.FilterIDs))
- for i, fltrID := range ap.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, ap.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
@@ -337,9 +327,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(ctx *context.Context, args *utils
return nil, e
}
fltrIDs := make([]string, len(ap.FilterIDs))
- for i, fltrID := range ap.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, ap.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -359,9 +347,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexes(ctx *context.Context, args *utils
return nil, nil
}
fltrIDs := make([]string, len(dsp.FilterIDs))
- for i, fltrID := range dsp.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, dsp.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrDSPProfileNotFound {
return utils.APIErrorHandler(err)
@@ -451,9 +437,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(ctx *context.Context, args *util
return nil, e
}
fltrIDs := make([]string, len(th.FilterIDs))
- for i, fltrID := range th.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, th.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -470,9 +454,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(ctx *context.Context, args *util
}
cacheIDs[utils.CacheStatFilterIndexes] = []string{sq.ID}
fltrIDs := make([]string, len(sq.FilterIDs))
- for i, fltrID := range sq.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, sq.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -489,9 +471,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(ctx *context.Context, args *util
}
cacheIDs[utils.CacheResourceFilterIndexes] = []string{rp.ID}
fltrIDs := make([]string, len(rp.FilterIDs))
- for i, fltrID := range rp.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, rp.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -508,9 +488,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(ctx *context.Context, args *util
}
cacheIDs[utils.CacheRouteFilterIndexes] = []string{rp.ID}
fltrIDs := make([]string, len(rp.FilterIDs))
- for i, fltrID := range rp.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, rp.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -529,9 +507,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(ctx *context.Context, args *util
return nil, nil
}
fltrIDs := make([]string, len(ap.FilterIDs))
- for i, fltrID := range ap.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, ap.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -547,9 +523,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(ctx *context.Context, args *util
return nil, e
}
fltrIDs := make([]string, len(ap.FilterIDs))
- for i, fltrID := range ap.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, ap.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -568,9 +542,7 @@ func (apierSv1 *APIerSv1) ComputeFilterIndexIDs(ctx *context.Context, args *util
return nil, nil
}
fltrIDs := make([]string, len(dsp.FilterIDs))
- for i, fltrID := range dsp.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, dsp.FilterIDs)
return &fltrIDs, nil
}, nil); err != nil && err != utils.ErrDSPProfileNotFound {
return utils.APIErrorHandler(err)
diff --git a/apier/v1/triggers.go b/apier/v1/triggers.go
index c0b1ee02c..bf9e61dcc 100644
--- a/apier/v1/triggers.go
+++ b/apier/v1/triggers.go
@@ -188,7 +188,7 @@ func (apierSv1 *APIerSv1) ResetAccountActionTriggers(ctx *context.Context, attr
}
}
- if attr.Executed == false {
+ if !attr.Executed {
account.ExecuteActionTriggers(nil, apierSv1.FilterS)
}
return apierSv1.DataManager.SetAccount(account)
diff --git a/cmd/cgr-console/cgr-console.go b/cmd/cgr-console/cgr-console.go
index dce983fd7..227485566 100644
--- a/cmd/cgr-console/cgr-console.go
+++ b/cmd/cgr-console/cgr-console.go
@@ -99,15 +99,15 @@ func executeCommand(command string, client *rpcclient.RPCClient) {
if cmd.RpcMethod() != utils.EmptyString {
res := cmd.RpcResult()
param := cmd.RpcParams(false)
- switch param.(type) {
+ switch p := param.(type) {
case *console.EmptyWrapper:
param = utils.EmptyString
case *console.StringWrapper:
- param = param.(*console.StringWrapper).Item
+ param = p.Item
case *console.StringSliceWrapper:
- param = param.(*console.StringSliceWrapper).Items
+ param = p.Items
case *console.StringMapWrapper:
- param = param.(*console.StringMapWrapper).Items
+ param = p.Items
}
if rpcErr := client.Call(context.TODO(), cmd.RpcMethod(), param, res); rpcErr != nil {
diff --git a/cmd/cgr-tester/filereader.go b/cmd/cgr-tester/filereader.go
index 36db75718..ec0ba7c49 100644
--- a/cmd/cgr-tester/filereader.go
+++ b/cmd/cgr-tester/filereader.go
@@ -19,7 +19,6 @@ along with this program. If not, see
package main
import (
- "bufio"
"bytes"
"io"
"log"
@@ -52,9 +51,8 @@ type FileReaderTester struct {
runs int
reqSep []byte
- rdr io.Reader
- conn net.Conn
- connScnr *bufio.Scanner
+ rdr io.Reader
+ conn net.Conn
}
func (frt *FileReaderTester) connSendReq(req []byte) (err error) {
diff --git a/config/apiban.go b/config/apiban.go
index f43eac3f9..64aea4024 100644
--- a/config/apiban.go
+++ b/config/apiban.go
@@ -31,9 +31,7 @@ func (ban *APIBanCfg) loadFromJSONCfg(jsnCfg *APIBanJsonCfg) (err error) {
}
if jsnCfg.Keys != nil {
ban.Keys = make([]string, len(*jsnCfg.Keys))
- for i, key := range *jsnCfg.Keys {
- ban.Keys[i] = key
- }
+ copy(ban.Keys, *jsnCfg.Keys)
}
return nil
}
@@ -50,8 +48,6 @@ func (ban APIBanCfg) Clone() (cln *APIBanCfg) {
cln = &APIBanCfg{
Keys: make([]string, len(ban.Keys)),
}
- for i, k := range ban.Keys {
- cln.Keys[i] = k
- }
+ copy(cln.Keys, ban.Keys)
return
}
diff --git a/config/apiercfg.go b/config/apiercfg.go
index 1f2b56f9f..d5894a6a4 100644
--- a/config/apiercfg.go
+++ b/config/apiercfg.go
@@ -136,27 +136,19 @@ func (aCfg ApierCfg) Clone() (cln *ApierCfg) {
}
if aCfg.CachesConns != nil {
cln.CachesConns = make([]string, len(aCfg.CachesConns))
- for i, k := range aCfg.CachesConns {
- cln.CachesConns[i] = k
- }
+ copy(cln.CachesConns, aCfg.CachesConns)
}
if aCfg.SchedulerConns != nil {
cln.SchedulerConns = make([]string, len(aCfg.SchedulerConns))
- for i, k := range aCfg.SchedulerConns {
- cln.SchedulerConns[i] = k
- }
+ copy(cln.SchedulerConns, aCfg.SchedulerConns)
}
if aCfg.AttributeSConns != nil {
cln.AttributeSConns = make([]string, len(aCfg.AttributeSConns))
- for i, k := range aCfg.AttributeSConns {
- cln.AttributeSConns[i] = k
- }
+ copy(cln.AttributeSConns, aCfg.AttributeSConns)
}
if aCfg.EEsConns != nil {
cln.EEsConns = make([]string, len(aCfg.EEsConns))
- for i, k := range aCfg.EEsConns {
- cln.EEsConns[i] = k
- }
+ copy(cln.EEsConns, aCfg.EEsConns)
}
return
}
diff --git a/config/attributescfg.go b/config/attributescfg.go
index b8453a906..2032569d4 100644
--- a/config/attributescfg.go
+++ b/config/attributescfg.go
@@ -110,23 +110,17 @@ func (alS *AttributeSCfg) loadFromJSONCfg(jsnCfg *AttributeSJsonCfg) (err error)
}
if jsnCfg.String_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.String_indexed_fields)
alS.StringIndexedFields = &sif
}
if jsnCfg.Prefix_indexed_fields != nil {
pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
+ copy(pif, *jsnCfg.Prefix_indexed_fields)
alS.PrefixIndexedFields = &pif
}
if jsnCfg.Suffix_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.Suffix_indexed_fields)
alS.SuffixIndexedFields = &sif
}
if jsnCfg.Nested_fields != nil {
@@ -161,23 +155,17 @@ func (alS *AttributeSCfg) AsMapInterface() (initialMP map[string]any) {
}
if alS.StringIndexedFields != nil {
stringIndexedFields := make([]string, len(*alS.StringIndexedFields))
- for i, item := range *alS.StringIndexedFields {
- stringIndexedFields[i] = item
- }
+ copy(stringIndexedFields, *alS.StringIndexedFields)
initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
}
if alS.PrefixIndexedFields != nil {
prefixIndexedFields := make([]string, len(*alS.PrefixIndexedFields))
- for i, item := range *alS.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
+ copy(prefixIndexedFields, *alS.PrefixIndexedFields)
initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
}
if alS.SuffixIndexedFields != nil {
suffixIndexedFields := make([]string, len(*alS.SuffixIndexedFields))
- for i, item := range *alS.SuffixIndexedFields {
- suffixIndexedFields[i] = item
- }
+ copy(suffixIndexedFields, *alS.SuffixIndexedFields)
initialMP[utils.SuffixIndexedFieldsCfg] = suffixIndexedFields
}
if alS.StatSConns != nil {
@@ -239,42 +227,30 @@ func (alS AttributeSCfg) Clone() (cln *AttributeSCfg) {
}
if alS.ResourceSConns != nil {
cln.ResourceSConns = make([]string, len(alS.ResourceSConns))
- for i, con := range alS.ResourceSConns {
- cln.ResourceSConns[i] = con
- }
+ copy(cln.ResourceSConns, alS.ResourceSConns)
}
if alS.StatSConns != nil {
cln.StatSConns = make([]string, len(alS.StatSConns))
- for i, con := range alS.StatSConns {
- cln.StatSConns[i] = con
- }
+ copy(cln.StatSConns, alS.StatSConns)
}
if alS.ApierSConns != nil {
cln.ApierSConns = make([]string, len(alS.ApierSConns))
- for i, con := range alS.ApierSConns {
- cln.ApierSConns[i] = con
- }
+ copy(cln.ApierSConns, alS.ApierSConns)
}
if alS.StringIndexedFields != nil {
idx := make([]string, len(*alS.StringIndexedFields))
- for i, dx := range *alS.StringIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *alS.StringIndexedFields)
cln.StringIndexedFields = &idx
}
if alS.PrefixIndexedFields != nil {
idx := make([]string, len(*alS.PrefixIndexedFields))
- for i, dx := range *alS.PrefixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *alS.PrefixIndexedFields)
cln.PrefixIndexedFields = &idx
}
if alS.SuffixIndexedFields != nil {
idx := make([]string, len(*alS.SuffixIndexedFields))
- for i, dx := range *alS.SuffixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *alS.SuffixIndexedFields)
cln.SuffixIndexedFields = &idx
}
return
diff --git a/config/cachecfg.go b/config/cachecfg.go
index e6f317dba..21ed133b7 100644
--- a/config/cachecfg.go
+++ b/config/cachecfg.go
@@ -120,9 +120,7 @@ func (cCfg *CacheCfg) loadFromJSONCfg(jsnCfg *CacheJsonCfg) (err error) {
}
if jsnCfg.Remote_conns != nil {
cCfg.RemoteConns = make([]string, len(*jsnCfg.Remote_conns))
- for idx, connID := range *jsnCfg.Remote_conns {
- cCfg.RemoteConns[idx] = connID
- }
+ copy(cCfg.RemoteConns, *jsnCfg.Remote_conns)
}
return nil
}
diff --git a/config/cdrscfg.go b/config/cdrscfg.go
index 1cbcd9937..d138bbeca 100644
--- a/config/cdrscfg.go
+++ b/config/cdrscfg.go
@@ -149,9 +149,8 @@ func (cdrscfg *CdrsCfg) AsMapInterface() (initialMP map[string]any) {
initialMP[utils.ExtraFieldsCfg] = extraFields
onlineCDRExports := make([]string, len(cdrscfg.OnlineCDRExports))
- for i, item := range cdrscfg.OnlineCDRExports {
- onlineCDRExports[i] = item
- }
+ copy(onlineCDRExports, cdrscfg.OnlineCDRExports)
+
initialMP[utils.OnlineCDRExportsCfg] = onlineCDRExports
if cdrscfg.ChargerSConns != nil {
@@ -237,51 +236,35 @@ func (cdrscfg CdrsCfg) Clone() (cln *CdrsCfg) {
}
if cdrscfg.ChargerSConns != nil {
cln.ChargerSConns = make([]string, len(cdrscfg.ChargerSConns))
- for i, con := range cdrscfg.ChargerSConns {
- cln.ChargerSConns[i] = con
- }
+ copy(cln.ChargerSConns, cdrscfg.ChargerSConns)
}
if cdrscfg.RaterConns != nil {
cln.RaterConns = make([]string, len(cdrscfg.RaterConns))
- for i, con := range cdrscfg.RaterConns {
- cln.RaterConns[i] = con
- }
+ copy(cln.RaterConns, cdrscfg.RaterConns)
}
if cdrscfg.AttributeSConns != nil {
cln.AttributeSConns = make([]string, len(cdrscfg.AttributeSConns))
- for i, con := range cdrscfg.AttributeSConns {
- cln.AttributeSConns[i] = con
- }
+ copy(cln.AttributeSConns, cdrscfg.AttributeSConns)
}
if cdrscfg.ThresholdSConns != nil {
cln.ThresholdSConns = make([]string, len(cdrscfg.ThresholdSConns))
- for i, con := range cdrscfg.ThresholdSConns {
- cln.ThresholdSConns[i] = con
- }
+ copy(cln.ThresholdSConns, cdrscfg.ThresholdSConns)
}
if cdrscfg.StatSConns != nil {
cln.StatSConns = make([]string, len(cdrscfg.StatSConns))
- for i, con := range cdrscfg.StatSConns {
- cln.StatSConns[i] = con
- }
+ copy(cln.StatSConns, cdrscfg.StatSConns)
}
if cdrscfg.OnlineCDRExports != nil {
cln.OnlineCDRExports = make([]string, len(cdrscfg.OnlineCDRExports))
- for i, con := range cdrscfg.OnlineCDRExports {
- cln.OnlineCDRExports[i] = con
- }
+ copy(cln.OnlineCDRExports, cdrscfg.OnlineCDRExports)
}
if cdrscfg.SchedulerConns != nil {
cln.SchedulerConns = make([]string, len(cdrscfg.SchedulerConns))
- for i, con := range cdrscfg.SchedulerConns {
- cln.SchedulerConns[i] = con
- }
+ copy(cln.SchedulerConns, cdrscfg.SchedulerConns)
}
if cdrscfg.EEsConns != nil {
cln.EEsConns = make([]string, len(cdrscfg.EEsConns))
- for i, con := range cdrscfg.EEsConns {
- cln.EEsConns[i] = con
- }
+ copy(cln.EEsConns, cdrscfg.EEsConns)
}
return
diff --git a/config/chargerscfg.go b/config/chargerscfg.go
index 8487822f2..77c0dcb5c 100644
--- a/config/chargerscfg.go
+++ b/config/chargerscfg.go
@@ -55,23 +55,17 @@ func (cS *ChargerSCfg) loadFromJSONCfg(jsnCfg *ChargerSJsonCfg) (err error) {
}
if jsnCfg.String_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.String_indexed_fields)
cS.StringIndexedFields = &sif
}
if jsnCfg.Prefix_indexed_fields != nil {
pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
+ copy(pif, *jsnCfg.Prefix_indexed_fields)
cS.PrefixIndexedFields = &pif
}
if jsnCfg.Suffix_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.Suffix_indexed_fields)
cS.SuffixIndexedFields = &sif
}
if jsnCfg.Nested_fields != nil {
@@ -99,23 +93,17 @@ func (cS *ChargerSCfg) AsMapInterface() (initialMP map[string]any) {
}
if cS.StringIndexedFields != nil {
stringIndexedFields := make([]string, len(*cS.StringIndexedFields))
- for i, item := range *cS.StringIndexedFields {
- stringIndexedFields[i] = item
- }
+ copy(stringIndexedFields, *cS.StringIndexedFields)
initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
}
if cS.PrefixIndexedFields != nil {
prefixIndexedFields := make([]string, len(*cS.PrefixIndexedFields))
- for i, item := range *cS.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
+ copy(prefixIndexedFields, *cS.PrefixIndexedFields)
initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
}
if cS.SuffixIndexedFields != nil {
sufixIndexedFields := make([]string, len(*cS.SuffixIndexedFields))
- for i, item := range *cS.SuffixIndexedFields {
- sufixIndexedFields[i] = item
- }
+ copy(sufixIndexedFields, *cS.SuffixIndexedFields)
initialMP[utils.SuffixIndexedFieldsCfg] = sufixIndexedFields
}
return
@@ -130,30 +118,22 @@ func (cS ChargerSCfg) Clone() (cln *ChargerSCfg) {
}
if cS.AttributeSConns != nil {
cln.AttributeSConns = make([]string, len(cS.AttributeSConns))
- for i, con := range cS.AttributeSConns {
- cln.AttributeSConns[i] = con
- }
+ copy(cln.AttributeSConns, cS.AttributeSConns)
}
if cS.StringIndexedFields != nil {
idx := make([]string, len(*cS.StringIndexedFields))
- for i, dx := range *cS.StringIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *cS.StringIndexedFields)
cln.StringIndexedFields = &idx
}
if cS.PrefixIndexedFields != nil {
idx := make([]string, len(*cS.PrefixIndexedFields))
- for i, dx := range *cS.PrefixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *cS.PrefixIndexedFields)
cln.PrefixIndexedFields = &idx
}
if cS.SuffixIndexedFields != nil {
idx := make([]string, len(*cS.SuffixIndexedFields))
- for i, dx := range *cS.SuffixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *cS.SuffixIndexedFields)
cln.SuffixIndexedFields = &idx
}
return
diff --git a/config/datadbcfg.go b/config/datadbcfg.go
index 365500db5..343dff954 100644
--- a/config/datadbcfg.go
+++ b/config/datadbcfg.go
@@ -239,15 +239,11 @@ func (dbcfg *DataDbCfg) Clone() (cln *DataDbCfg) {
}
if dbcfg.RmtConns != nil {
cln.RmtConns = make([]string, len(dbcfg.RmtConns))
- for i, conn := range dbcfg.RmtConns {
- cln.RmtConns[i] = conn
- }
+ copy(cln.RmtConns, dbcfg.RmtConns)
}
if dbcfg.RplConns != nil {
cln.RplConns = make([]string, len(dbcfg.RplConns))
- for i, conn := range dbcfg.RplConns {
- cln.RplConns[i] = conn
- }
+ copy(cln.RplConns, dbcfg.RplConns)
}
return
}
diff --git a/config/diametercfg.go b/config/diametercfg.go
index 661de89a6..cba4cb1e9 100644
--- a/config/diametercfg.go
+++ b/config/diametercfg.go
@@ -176,9 +176,7 @@ func (da DiameterAgentCfg) Clone() (cln *DiameterAgentCfg) {
}
if da.SessionSConns != nil {
cln.SessionSConns = make([]string, len(da.SessionSConns))
- for i, con := range da.SessionSConns {
- cln.SessionSConns[i] = con
- }
+ copy(cln.SessionSConns, da.SessionSConns)
}
if da.RequestProcessors != nil {
cln.RequestProcessors = make([]*RequestProcessor, len(da.RequestProcessors))
diff --git a/config/dispatcherscfg.go b/config/dispatcherscfg.go
index 2caf566c0..6fbd45b44 100644
--- a/config/dispatcherscfg.go
+++ b/config/dispatcherscfg.go
@@ -47,23 +47,17 @@ func (dps *DispatcherSCfg) loadFromJSONCfg(jsnCfg *DispatcherSJsonCfg) (err erro
}
if jsnCfg.String_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.String_indexed_fields)
dps.StringIndexedFields = &sif
}
if jsnCfg.Prefix_indexed_fields != nil {
pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
+ copy(pif, *jsnCfg.Prefix_indexed_fields)
dps.PrefixIndexedFields = &pif
}
if jsnCfg.Suffix_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.Suffix_indexed_fields)
dps.SuffixIndexedFields = &sif
}
if jsnCfg.Attributes_conns != nil {
@@ -99,23 +93,17 @@ func (dps *DispatcherSCfg) AsMapInterface() (mp map[string]any) {
}
if dps.StringIndexedFields != nil {
stringIndexedFields := make([]string, len(*dps.StringIndexedFields))
- for i, item := range *dps.StringIndexedFields {
- stringIndexedFields[i] = item
- }
+ copy(stringIndexedFields, *dps.StringIndexedFields)
mp[utils.StringIndexedFieldsCfg] = stringIndexedFields
}
if dps.PrefixIndexedFields != nil {
prefixIndexedFields := make([]string, len(*dps.PrefixIndexedFields))
- for i, item := range *dps.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
+ copy(prefixIndexedFields, *dps.PrefixIndexedFields)
mp[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
}
if dps.SuffixIndexedFields != nil {
suffixIndexedFields := make([]string, len(*dps.SuffixIndexedFields))
- for i, item := range *dps.SuffixIndexedFields {
- suffixIndexedFields[i] = item
- }
+ copy(suffixIndexedFields, *dps.SuffixIndexedFields)
mp[utils.SuffixIndexedFieldsCfg] = suffixIndexedFields
}
if dps.AttributeSConns != nil {
@@ -143,29 +131,21 @@ func (dps DispatcherSCfg) Clone() (cln *DispatcherSCfg) {
if dps.AttributeSConns != nil {
cln.AttributeSConns = make([]string, len(dps.AttributeSConns))
- for i, conn := range dps.AttributeSConns {
- cln.AttributeSConns[i] = conn
- }
+ copy(cln.AttributeSConns, dps.AttributeSConns)
}
if dps.StringIndexedFields != nil {
idx := make([]string, len(*dps.StringIndexedFields))
- for i, dx := range *dps.StringIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *dps.StringIndexedFields)
cln.StringIndexedFields = &idx
}
if dps.PrefixIndexedFields != nil {
idx := make([]string, len(*dps.PrefixIndexedFields))
- for i, dx := range *dps.PrefixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *dps.PrefixIndexedFields)
cln.PrefixIndexedFields = &idx
}
if dps.SuffixIndexedFields != nil {
idx := make([]string, len(*dps.SuffixIndexedFields))
- for i, dx := range *dps.SuffixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *dps.SuffixIndexedFields)
cln.SuffixIndexedFields = &idx
}
return
diff --git a/config/dnsagntcfg.go b/config/dnsagntcfg.go
index 7f9d2e373..c8c88f026 100644
--- a/config/dnsagntcfg.go
+++ b/config/dnsagntcfg.go
@@ -148,9 +148,7 @@ func (da DNSAgentCfg) Clone() (cln *DNSAgentCfg) {
if da.SessionSConns != nil {
cln.SessionSConns = make([]string, len(da.SessionSConns))
- for i, con := range da.SessionSConns {
- cln.SessionSConns[i] = con
- }
+ copy(cln.SessionSConns, da.SessionSConns)
}
if da.RequestProcessors != nil {
cln.RequestProcessors = make([]*RequestProcessor, len(da.RequestProcessors))
@@ -181,9 +179,7 @@ func (rp *RequestProcessor) loadFromJSONCfg(jsnCfg *ReqProcessorJsnCfg, sep stri
}
if jsnCfg.Filters != nil {
rp.Filters = make([]string, len(*jsnCfg.Filters))
- for i, fltr := range *jsnCfg.Filters {
- rp.Filters[i] = fltr
- }
+ copy(rp.Filters, *jsnCfg.Filters)
}
if jsnCfg.Flags != nil {
rp.Flags = utils.FlagsWithParamsFromSlice(*jsnCfg.Flags)
@@ -247,9 +243,8 @@ func (rp RequestProcessor) Clone() (cln *RequestProcessor) {
}
if rp.Filters != nil {
cln.Filters = make([]string, len(rp.Filters))
- for i, fltr := range rp.Filters {
- cln.Filters[i] = fltr
- }
+ copy(cln.Filters, rp.Filters)
+
}
if rp.RequestFields != nil {
cln.RequestFields = make([]*FCTemplate, len(rp.RequestFields))
diff --git a/config/eescfg.go b/config/eescfg.go
index 5c30ec0e3..0cdba0b76 100644
--- a/config/eescfg.go
+++ b/config/eescfg.go
@@ -109,9 +109,8 @@ func (eeS *EEsCfg) Clone() (cln *EEsCfg) {
Cache: make(map[string]*CacheParamCfg),
Exporters: make([]*EventExporterCfg, len(eeS.Exporters)),
}
- for idx, sConn := range eeS.AttributeSConns {
- cln.AttributeSConns[idx] = sConn
- }
+
+ copy(cln.AttributeSConns, eeS.AttributeSConns)
for key, value := range eeS.Cache {
cln.Cache[key] = value.Clone()
}
@@ -577,9 +576,7 @@ func (eeC *EventExporterCfg) loadFromJSONCfg(jsnEec *EventExporterJsonCfg, msgTe
}
if jsnEec.Filters != nil {
eeC.Filters = make([]string, len(*jsnEec.Filters))
- for i, fltr := range *jsnEec.Filters {
- eeC.Filters[i] = fltr
- }
+ copy(eeC.Filters, *jsnEec.Filters)
}
if jsnEec.Flags != nil {
eeC.Flags = utils.FlagsWithParamsFromSlice(*jsnEec.Flags)
@@ -589,9 +586,8 @@ func (eeC *EventExporterCfg) loadFromJSONCfg(jsnEec *EventExporterJsonCfg, msgTe
}
if jsnEec.Attribute_ids != nil {
eeC.AttributeSIDs = make([]string, len(*jsnEec.Attribute_ids))
- for i, fltr := range *jsnEec.Attribute_ids {
- eeC.AttributeSIDs[i] = fltr
- }
+ copy(eeC.AttributeSIDs, *jsnEec.Attribute_ids)
+
}
if jsnEec.Synchronous != nil {
eeC.Synchronous = *jsnEec.Synchronous
@@ -940,15 +936,11 @@ func (eeC EventExporterCfg) Clone() (cln *EventExporterCfg) {
if eeC.Filters != nil {
cln.Filters = make([]string, len(eeC.Filters))
- for idx, val := range eeC.Filters {
- cln.Filters[idx] = val
- }
+ copy(cln.Filters, eeC.Filters)
}
if eeC.AttributeSIDs != nil {
cln.AttributeSIDs = make([]string, len(eeC.AttributeSIDs))
- for idx, val := range eeC.AttributeSIDs {
- cln.AttributeSIDs[idx] = val
- }
+ copy(cln.AttributeSIDs, eeC.AttributeSIDs)
}
for idx, fld := range eeC.Fields {
diff --git a/config/erscfg.go b/config/erscfg.go
index 56ec3ab6c..aa09d3a31 100644
--- a/config/erscfg.go
+++ b/config/erscfg.go
@@ -97,9 +97,9 @@ func (erS *ERsCfg) Clone() (cln *ERsCfg) {
Readers: make([]*EventReaderCfg, len(erS.Readers)),
PartialCacheTTL: erS.PartialCacheTTL,
}
- for idx, sConn := range erS.SessionSConns {
- cln.SessionSConns[idx] = sConn
- }
+
+ copy(cln.SessionSConns, erS.SessionSConns)
+
for idx, rdr := range erS.Readers {
cln.Readers[idx] = rdr.Clone()
}
@@ -534,9 +534,7 @@ func (er *EventReaderCfg) loadFromJSONCfg(jsnCfg *EventReaderJsonCfg, msgTemplat
}
if jsnCfg.Filters != nil {
er.Filters = make([]string, len(*jsnCfg.Filters))
- for i, fltr := range *jsnCfg.Filters {
- er.Filters[i] = fltr
- }
+ copy(er.Filters, *jsnCfg.Filters)
}
if jsnCfg.Flags != nil {
er.Flags = utils.FlagsWithParamsFromSlice(*jsnCfg.Flags)
@@ -900,9 +898,7 @@ func (er EventReaderCfg) Clone() (cln *EventReaderCfg) {
}
if er.Filters != nil {
cln.Filters = make([]string, len(er.Filters))
- for idx, val := range er.Filters {
- cln.Filters[idx] = val
- }
+ copy(cln.Filters, er.Filters)
}
if er.Fields != nil {
cln.Fields = make([]*FCTemplate, len(er.Fields))
diff --git a/config/fctemplate.go b/config/fctemplate.go
index 38fdfcc6d..5b445f9e2 100644
--- a/config/fctemplate.go
+++ b/config/fctemplate.go
@@ -43,9 +43,7 @@ func NewFCTemplateFromFCTemplateJSONCfg(jsnCfg *FcTemplateJsonCfg, separator str
}
if jsnCfg.Filters != nil {
fcTmp.Filters = make([]string, len(*jsnCfg.Filters))
- for i, fltr := range *jsnCfg.Filters {
- fcTmp.Filters[i] = fltr
- }
+ copy(fcTmp.Filters, *jsnCfg.Filters)
}
if jsnCfg.Value != nil {
if fcTmp.Value, err = NewRSRParsers(*jsnCfg.Value, separator); err != nil {
diff --git a/config/filterscfg.go b/config/filterscfg.go
index e023e61a1..04fb61482 100644
--- a/config/filterscfg.go
+++ b/config/filterscfg.go
@@ -107,21 +107,15 @@ func (fSCfg FilterSCfg) Clone() (cln *FilterSCfg) {
cln = new(FilterSCfg)
if fSCfg.StatSConns != nil {
cln.StatSConns = make([]string, len(fSCfg.StatSConns))
- for i, con := range fSCfg.StatSConns {
- cln.StatSConns[i] = con
- }
+ copy(cln.StatSConns, fSCfg.StatSConns)
}
if fSCfg.ResourceSConns != nil {
cln.ResourceSConns = make([]string, len(fSCfg.ResourceSConns))
- for i, con := range fSCfg.ResourceSConns {
- cln.ResourceSConns[i] = con
- }
+ copy(cln.ResourceSConns, fSCfg.ResourceSConns)
}
if fSCfg.ApierSConns != nil {
cln.ApierSConns = make([]string, len(fSCfg.ApierSConns))
- for i, con := range fSCfg.ApierSConns {
- cln.ApierSConns[i] = con
- }
+ copy(cln.ApierSConns, fSCfg.ApierSConns)
}
return
}
diff --git a/config/httpagntcfg.go b/config/httpagntcfg.go
index 83929d466..e0b1ea116 100644
--- a/config/httpagntcfg.go
+++ b/config/httpagntcfg.go
@@ -183,9 +183,7 @@ func (ha HTTPAgentCfg) Clone() (cln *HTTPAgentCfg) {
}
if ha.SessionSConns != nil {
cln.SessionSConns = make([]string, len(ha.SessionSConns))
- for i, con := range ha.SessionSConns {
- cln.SessionSConns[i] = con
- }
+ copy(cln.SessionSConns, ha.SessionSConns)
}
for i, req := range ha.RequestProcessors {
cln.RequestProcessors[i] = req.Clone()
diff --git a/config/kamagentcfg.go b/config/kamagentcfg.go
index 1dc411e0f..68df172e9 100644
--- a/config/kamagentcfg.go
+++ b/config/kamagentcfg.go
@@ -164,9 +164,7 @@ func (ka KamAgentCfg) Clone() (cln *KamAgentCfg) {
}
if ka.SessionSConns != nil {
cln.SessionSConns = make([]string, len(ka.SessionSConns))
- for i, con := range ka.SessionSConns {
- cln.SessionSConns[i] = con
- }
+ copy(cln.SessionSConns, ka.SessionSConns)
}
if ka.EvapiConns != nil {
cln.EvapiConns = make([]*KamConnCfg, len(ka.EvapiConns))
diff --git a/config/loadercgrcfg.go b/config/loadercgrcfg.go
index 39c579728..84cb5e98e 100644
--- a/config/loadercgrcfg.go
+++ b/config/loadercgrcfg.go
@@ -132,15 +132,11 @@ func (ld LoaderCgrCfg) Clone() (cln *LoaderCgrCfg) {
if ld.CachesConns != nil {
cln.CachesConns = make([]string, len(ld.CachesConns))
- for i, k := range ld.CachesConns {
- cln.CachesConns[i] = k
- }
+ copy(cln.CachesConns, ld.CachesConns)
}
if ld.SchedulerConns != nil {
cln.SchedulerConns = make([]string, len(ld.SchedulerConns))
- for i, k := range ld.SchedulerConns {
- cln.SchedulerConns[i] = k
- }
+ copy(cln.SchedulerConns, ld.SchedulerConns)
}
return
}
diff --git a/config/loaderscfg.go b/config/loaderscfg.go
index 73061da36..41b265d22 100644
--- a/config/loaderscfg.go
+++ b/config/loaderscfg.go
@@ -215,9 +215,9 @@ func (l LoaderSCfg) Clone() (cln *LoaderSCfg) {
TpOutDir: l.TpOutDir,
Data: make([]*LoaderDataType, len(l.Data)),
}
- for idx, connID := range l.CacheSConns {
- cln.CacheSConns[idx] = connID
- }
+
+ copy(cln.CacheSConns, l.CacheSConns)
+
for idx, fld := range l.Data {
cln.Data[idx] = fld.Clone()
}
diff --git a/config/migratorcfg.go b/config/migratorcfg.go
index a5578e2cc..26beb2d69 100644
--- a/config/migratorcfg.go
+++ b/config/migratorcfg.go
@@ -99,9 +99,7 @@ func (mg *MigratorCgrCfg) loadFromJSONCfg(jsnCfg *MigratorCfgJson) (err error) {
}
if jsnCfg.Users_filters != nil && len(*jsnCfg.Users_filters) != 0 {
mg.UsersFilters = make([]string, len(*jsnCfg.Users_filters))
- for i, v := range *jsnCfg.Users_filters {
- mg.UsersFilters[i] = v
- }
+ copy(mg.UsersFilters, *jsnCfg.Users_filters)
}
if jsnCfg.Out_dataDB_opts != nil {
err = mg.OutDataDBOpts.loadFromJSONCfg(jsnCfg.Out_dataDB_opts)
diff --git a/config/radiuscfg.go b/config/radiuscfg.go
index 6e88b3e94..6e4d26823 100644
--- a/config/radiuscfg.go
+++ b/config/radiuscfg.go
@@ -148,9 +148,7 @@ func (ra RadiusAgentCfg) Clone() (cln *RadiusAgentCfg) {
}
if ra.SessionSConns != nil {
cln.SessionSConns = make([]string, len(ra.SessionSConns))
- for i, con := range ra.SessionSConns {
- cln.SessionSConns[i] = con
- }
+ copy(cln.SessionSConns, ra.SessionSConns)
}
for k, v := range ra.ClientSecrets {
cln.ClientSecrets[k] = v
diff --git a/config/ralscfg.go b/config/ralscfg.go
index 63061dafa..4d4c9e0b2 100644
--- a/config/ralscfg.go
+++ b/config/ralscfg.go
@@ -148,15 +148,11 @@ func (ralsCfg RalsCfg) Clone() (cln *RalsCfg) {
}
if ralsCfg.ThresholdSConns != nil {
cln.ThresholdSConns = make([]string, len(ralsCfg.ThresholdSConns))
- for i, con := range ralsCfg.ThresholdSConns {
- cln.ThresholdSConns[i] = con
- }
+ copy(cln.ThresholdSConns, ralsCfg.ThresholdSConns)
}
if ralsCfg.StatSConns != nil {
cln.StatSConns = make([]string, len(ralsCfg.StatSConns))
- for i, con := range ralsCfg.StatSConns {
- cln.StatSConns[i] = con
- }
+ copy(cln.StatSConns, ralsCfg.StatSConns)
}
for k, u := range ralsCfg.MaxComputedUsage {
diff --git a/config/registrarccfg.go b/config/registrarccfg.go
index e5eba1849..f05b13fab 100644
--- a/config/registrarccfg.go
+++ b/config/registrarccfg.go
@@ -127,9 +127,7 @@ func (dps RegistrarCCfg) Clone() (cln *RegistrarCCfg) {
}
if dps.RegistrarSConns != nil {
cln.RegistrarSConns = make([]string, len(dps.RegistrarSConns))
- for i, k := range dps.RegistrarSConns {
- cln.RegistrarSConns[i] = k
- }
+ copy(cln.RegistrarSConns, dps.RegistrarSConns)
}
for tnt, hosts := range dps.Hosts {
clnH := make([]*RemoteHost, len(hosts))
diff --git a/config/resourcescfg.go b/config/resourcescfg.go
index 65bf57b20..3ab93938d 100644
--- a/config/resourcescfg.go
+++ b/config/resourcescfg.go
@@ -90,23 +90,17 @@ func (rlcfg *ResourceSConfig) loadFromJSONCfg(jsnCfg *ResourceSJsonCfg) (err err
}
if jsnCfg.String_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.String_indexed_fields)
rlcfg.StringIndexedFields = &sif
}
if jsnCfg.Prefix_indexed_fields != nil {
pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
+ copy(pif, *jsnCfg.Prefix_indexed_fields)
rlcfg.PrefixIndexedFields = &pif
}
if jsnCfg.Suffix_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.Suffix_indexed_fields)
rlcfg.SuffixIndexedFields = &sif
}
if jsnCfg.Nested_fields != nil {
@@ -146,23 +140,17 @@ func (rlcfg *ResourceSConfig) AsMapInterface() (initialMP map[string]any) {
}
if rlcfg.StringIndexedFields != nil {
stringIndexedFields := make([]string, len(*rlcfg.StringIndexedFields))
- for i, item := range *rlcfg.StringIndexedFields {
- stringIndexedFields[i] = item
- }
+ copy(stringIndexedFields, *rlcfg.StringIndexedFields)
initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
}
if rlcfg.PrefixIndexedFields != nil {
prefixIndexedFields := make([]string, len(*rlcfg.PrefixIndexedFields))
- for i, item := range *rlcfg.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
+ copy(prefixIndexedFields, *rlcfg.PrefixIndexedFields)
initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
}
if rlcfg.SuffixIndexedFields != nil {
suffixIndexedFields := make([]string, len(*rlcfg.SuffixIndexedFields))
- for i, item := range *rlcfg.SuffixIndexedFields {
- suffixIndexedFields[i] = item
- }
+ copy(suffixIndexedFields, *rlcfg.SuffixIndexedFields)
initialMP[utils.SuffixIndexedFieldsCfg] = suffixIndexedFields
}
if rlcfg.StoreInterval != 0 {
@@ -194,30 +182,22 @@ func (rlcfg ResourceSConfig) Clone() (cln *ResourceSConfig) {
}
if rlcfg.ThresholdSConns != nil {
cln.ThresholdSConns = make([]string, len(rlcfg.ThresholdSConns))
- for i, con := range rlcfg.ThresholdSConns {
- cln.ThresholdSConns[i] = con
- }
+ copy(cln.ThresholdSConns, rlcfg.ThresholdSConns)
}
if rlcfg.StringIndexedFields != nil {
idx := make([]string, len(*rlcfg.StringIndexedFields))
- for i, dx := range *rlcfg.StringIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *rlcfg.StringIndexedFields)
cln.StringIndexedFields = &idx
}
if rlcfg.PrefixIndexedFields != nil {
idx := make([]string, len(*rlcfg.PrefixIndexedFields))
- for i, dx := range *rlcfg.PrefixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *rlcfg.PrefixIndexedFields)
cln.PrefixIndexedFields = &idx
}
if rlcfg.SuffixIndexedFields != nil {
idx := make([]string, len(*rlcfg.SuffixIndexedFields))
- for i, dx := range *rlcfg.SuffixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *rlcfg.SuffixIndexedFields)
cln.SuffixIndexedFields = &idx
}
return
diff --git a/config/rjreader_test.go b/config/rjreader_test.go
index 556902748..bd26ab8a7 100644
--- a/config/rjreader_test.go
+++ b/config/rjreader_test.go
@@ -304,14 +304,6 @@ func TestHandleJSONErrorNil(t *testing.T) {
}
}
-func TestHandleJSONErrorInvalidUTF8(t *testing.T) {
- rjr := NewRjReaderFromBytes([]byte("{}"))
- expectedErr := new(json.InvalidUTF8Error)
- if err := rjr.HandleJSONError(expectedErr); err == nil || err.Error() != expectedErr.Error() {
- t.Errorf("Expected %+v, received %+v", expectedErr, err)
- }
-}
-
func TestHandleJSONErrorDefaultError(t *testing.T) {
rjr := NewRjReaderFromBytes([]byte("{}"))
rjr.indx = 10
diff --git a/config/routescfg.go b/config/routescfg.go
index 56c8bfdd7..b7bf11b9b 100644
--- a/config/routescfg.go
+++ b/config/routescfg.go
@@ -83,23 +83,17 @@ func (rts *RouteSCfg) loadFromJSONCfg(jsnCfg *RouteSJsonCfg) (err error) {
}
if jsnCfg.String_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.String_indexed_fields)
rts.StringIndexedFields = &sif
}
if jsnCfg.Prefix_indexed_fields != nil {
pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
+ copy(pif, *jsnCfg.Prefix_indexed_fields)
rts.PrefixIndexedFields = &pif
}
if jsnCfg.Suffix_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.Suffix_indexed_fields)
rts.SuffixIndexedFields = &sif
}
if jsnCfg.Attributes_conns != nil {
@@ -181,23 +175,17 @@ func (rts *RouteSCfg) AsMapInterface() (initialMP map[string]any) {
}
if rts.StringIndexedFields != nil {
stringIndexedFields := make([]string, len(*rts.StringIndexedFields))
- for i, item := range *rts.StringIndexedFields {
- stringIndexedFields[i] = item
- }
+ copy(stringIndexedFields, *rts.StringIndexedFields)
initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
}
if rts.PrefixIndexedFields != nil {
prefixIndexedFields := make([]string, len(*rts.PrefixIndexedFields))
- for i, item := range *rts.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
+ copy(prefixIndexedFields, *rts.PrefixIndexedFields)
initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
}
if rts.SuffixIndexedFields != nil {
suffixIndexedFieldsCfg := make([]string, len(*rts.SuffixIndexedFields))
- for i, item := range *rts.SuffixIndexedFields {
- suffixIndexedFieldsCfg[i] = item
- }
+ copy(suffixIndexedFieldsCfg, *rts.SuffixIndexedFields)
initialMP[utils.SuffixIndexedFieldsCfg] = suffixIndexedFieldsCfg
}
if rts.AttributeSConns != nil {
@@ -275,47 +263,33 @@ func (rts RouteSCfg) Clone() (cln *RouteSCfg) {
}
if rts.AttributeSConns != nil {
cln.AttributeSConns = make([]string, len(rts.AttributeSConns))
- for i, con := range rts.AttributeSConns {
- cln.AttributeSConns[i] = con
- }
+ copy(cln.AttributeSConns, rts.AttributeSConns)
}
if rts.ResourceSConns != nil {
cln.ResourceSConns = make([]string, len(rts.ResourceSConns))
- for i, con := range rts.ResourceSConns {
- cln.ResourceSConns[i] = con
- }
+ copy(cln.ResourceSConns, rts.ResourceSConns)
}
if rts.StatSConns != nil {
cln.StatSConns = make([]string, len(rts.StatSConns))
- for i, con := range rts.StatSConns {
- cln.StatSConns[i] = con
- }
+ copy(cln.StatSConns, rts.StatSConns)
}
if rts.RALsConns != nil {
cln.RALsConns = make([]string, len(rts.RALsConns))
- for i, con := range rts.RALsConns {
- cln.RALsConns[i] = con
- }
+ copy(cln.RALsConns, rts.RALsConns)
}
if rts.StringIndexedFields != nil {
idx := make([]string, len(*rts.StringIndexedFields))
- for i, dx := range *rts.StringIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *rts.StringIndexedFields)
cln.StringIndexedFields = &idx
}
if rts.PrefixIndexedFields != nil {
idx := make([]string, len(*rts.PrefixIndexedFields))
- for i, dx := range *rts.PrefixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *rts.PrefixIndexedFields)
cln.PrefixIndexedFields = &idx
}
if rts.SuffixIndexedFields != nil {
idx := make([]string, len(*rts.SuffixIndexedFields))
- for i, dx := range *rts.SuffixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *rts.SuffixIndexedFields)
cln.SuffixIndexedFields = &idx
}
return
diff --git a/config/rsrparser.go b/config/rsrparser.go
index 104ab9e01..68413fbc7 100644
--- a/config/rsrparser.go
+++ b/config/rsrparser.go
@@ -382,11 +382,9 @@ func (prsr RSRParser) Clone() (cln *RSRParser) {
}
if prsr.converters != nil {
cln.converters = make(utils.DataConverters, len(prsr.converters))
- for i, cnv := range prsr.converters {
- // we can't modify the convertor only overwirte it
- // safe to coppy it's value
- cln.converters[i] = cnv
- }
+ // we can't modify the convertor only overwirte it
+ // safe to coppy it's value
+ copy(cln.converters, prsr.converters)
}
return
}
diff --git a/config/schedulercfg.go b/config/schedulercfg.go
index 58878160b..4d764e543 100644
--- a/config/schedulercfg.go
+++ b/config/schedulercfg.go
@@ -51,9 +51,7 @@ func (schdcfg *SchedulerCfg) loadFromJSONCfg(jsnCfg *SchedulerJsonCfg) error {
}
if jsnCfg.Filters != nil {
schdcfg.Filters = make([]string, len(*jsnCfg.Filters))
- for i, fltr := range *jsnCfg.Filters {
- schdcfg.Filters[i] = fltr
- }
+ copy(schdcfg.Filters, *jsnCfg.Filters)
}
if jsnCfg.Thresholds_conns != nil {
schdcfg.ThreshSConns = make([]string, len(*jsnCfg.Thresholds_conns))
@@ -77,9 +75,7 @@ func (schdcfg *SchedulerCfg) loadFromJSONCfg(jsnCfg *SchedulerJsonCfg) error {
}
if jsnCfg.Dynaprepaid_actionplans != nil {
schdcfg.DynaprepaidActionPlans = make([]string, len(*jsnCfg.Dynaprepaid_actionplans))
- for i, val := range *jsnCfg.Dynaprepaid_actionplans {
- schdcfg.DynaprepaidActionPlans[i] = val
- }
+ copy(schdcfg.DynaprepaidActionPlans, *jsnCfg.Dynaprepaid_actionplans)
}
return nil
}
@@ -131,34 +127,25 @@ func (schdcfg SchedulerCfg) Clone() (cln *SchedulerCfg) {
}
if schdcfg.CDRsConns != nil {
cln.CDRsConns = make([]string, len(schdcfg.CDRsConns))
- for i, con := range schdcfg.CDRsConns {
- cln.CDRsConns[i] = con
- }
+ copy(cln.CDRsConns, schdcfg.CDRsConns)
}
if schdcfg.ThreshSConns != nil {
cln.ThreshSConns = make([]string, len(schdcfg.ThreshSConns))
- for i, con := range schdcfg.ThreshSConns {
- cln.ThreshSConns[i] = con
- }
+ copy(cln.ThreshSConns, schdcfg.ThreshSConns)
}
if schdcfg.StatSConns != nil {
cln.StatSConns = make([]string, len(schdcfg.StatSConns))
- for i, con := range schdcfg.StatSConns {
- cln.StatSConns[i] = con
- }
+ copy(cln.StatSConns, schdcfg.StatSConns)
}
+
if schdcfg.Filters != nil {
cln.Filters = make([]string, len(schdcfg.Filters))
- for i, con := range schdcfg.Filters {
- cln.Filters[i] = con
- }
+ copy(cln.Filters, schdcfg.Filters)
}
if schdcfg.DynaprepaidActionPlans != nil {
cln.DynaprepaidActionPlans = make([]string, len(schdcfg.DynaprepaidActionPlans))
- for i, con := range schdcfg.DynaprepaidActionPlans {
- cln.DynaprepaidActionPlans[i] = con
- }
+ copy(cln.DynaprepaidActionPlans, schdcfg.DynaprepaidActionPlans)
}
return
}
diff --git a/config/sessionscfg.go b/config/sessionscfg.go
index d005a3d6e..bcfad2263 100644
--- a/config/sessionscfg.go
+++ b/config/sessionscfg.go
@@ -512,63 +512,45 @@ func (scfg SessionSCfg) Clone() (cln *SessionSCfg) {
if scfg.ChargerSConns != nil {
cln.ChargerSConns = make([]string, len(scfg.ChargerSConns))
- for i, con := range scfg.ChargerSConns {
- cln.ChargerSConns[i] = con
- }
+ copy(cln.ChargerSConns, scfg.ChargerSConns)
+
}
if scfg.RALsConns != nil {
cln.RALsConns = make([]string, len(scfg.RALsConns))
- for i, con := range scfg.RALsConns {
- cln.RALsConns[i] = con
- }
+ copy(cln.RALsConns, scfg.RALsConns)
}
if scfg.ResSConns != nil {
cln.ResSConns = make([]string, len(scfg.ResSConns))
- for i, con := range scfg.ResSConns {
- cln.ResSConns[i] = con
- }
+ copy(cln.ResSConns, scfg.ResSConns)
}
if scfg.ThreshSConns != nil {
cln.ThreshSConns = make([]string, len(scfg.ThreshSConns))
- for i, con := range scfg.ThreshSConns {
- cln.ThreshSConns[i] = con
- }
+ copy(cln.ThreshSConns, scfg.ThreshSConns)
}
if scfg.StatSConns != nil {
cln.StatSConns = make([]string, len(scfg.StatSConns))
- for i, con := range scfg.StatSConns {
- cln.StatSConns[i] = con
- }
+ copy(cln.StatSConns, scfg.StatSConns)
}
if scfg.RouteSConns != nil {
cln.RouteSConns = make([]string, len(scfg.RouteSConns))
- for i, con := range scfg.RouteSConns {
- cln.RouteSConns[i] = con
- }
+ copy(cln.RouteSConns, scfg.RouteSConns)
}
if scfg.AttrSConns != nil {
cln.AttrSConns = make([]string, len(scfg.AttrSConns))
- for i, con := range scfg.AttrSConns {
- cln.AttrSConns[i] = con
- }
+ copy(cln.AttrSConns, scfg.AttrSConns)
}
if scfg.CDRsConns != nil {
cln.CDRsConns = make([]string, len(scfg.CDRsConns))
- for i, con := range scfg.CDRsConns {
- cln.CDRsConns[i] = con
- }
+ copy(cln.CDRsConns, scfg.CDRsConns)
+
}
if scfg.ReplicationConns != nil {
cln.ReplicationConns = make([]string, len(scfg.ReplicationConns))
- for i, con := range scfg.ReplicationConns {
- cln.ReplicationConns[i] = con
- }
+ copy(cln.ReplicationConns, scfg.ReplicationConns)
}
if scfg.SchedulerConns != nil {
cln.SchedulerConns = make([]string, len(scfg.SchedulerConns))
- for i, con := range scfg.SchedulerConns {
- cln.SchedulerConns[i] = con
- }
+ copy(cln.SchedulerConns, scfg.SchedulerConns)
}
return
@@ -698,9 +680,7 @@ func (fscfg FsAgentCfg) Clone() (cln *FsAgentCfg) {
}
if fscfg.SessionSConns != nil {
cln.SessionSConns = make([]string, len(fscfg.SessionSConns))
- for i, con := range fscfg.SessionSConns {
- cln.SessionSConns[i] = con
- }
+ copy(cln.SessionSConns, fscfg.SessionSConns)
}
if fscfg.EventSocketConns != nil {
cln.EventSocketConns = make([]*FsConnCfg, len(fscfg.EventSocketConns))
@@ -863,9 +843,7 @@ func (aCfg AsteriskAgentCfg) Clone() (cln *AsteriskAgentCfg) {
}
if aCfg.SessionSConns != nil {
cln.SessionSConns = make([]string, len(aCfg.SessionSConns))
- for i, con := range aCfg.SessionSConns {
- cln.SessionSConns[i] = con
- }
+ copy(cln.SessionSConns, aCfg.SessionSConns)
}
if aCfg.AsteriskConns != nil {
cln.AsteriskConns = make([]*AsteriskConnCfg, len(aCfg.AsteriskConns))
diff --git a/config/sipagentcfg.go b/config/sipagentcfg.go
index 67d5e77c6..dfb931761 100644
--- a/config/sipagentcfg.go
+++ b/config/sipagentcfg.go
@@ -128,9 +128,7 @@ func (sa SIPAgentCfg) Clone() (cln *SIPAgentCfg) {
}
if sa.SessionSConns != nil {
cln.SessionSConns = make([]string, len(sa.SessionSConns))
- for i, c := range sa.SessionSConns {
- cln.SessionSConns[i] = c
- }
+ copy(cln.SessionSConns, sa.SessionSConns)
}
if sa.RequestProcessors != nil {
cln.RequestProcessors = make([]*RequestProcessor, len(sa.RequestProcessors))
diff --git a/config/statscfg.go b/config/statscfg.go
index 8b5e64446..e816987c7 100644
--- a/config/statscfg.go
+++ b/config/statscfg.go
@@ -86,23 +86,17 @@ func (st *StatSCfg) loadFromJSONCfg(jsnCfg *StatServJsonCfg) (err error) {
}
if jsnCfg.String_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.String_indexed_fields)
st.StringIndexedFields = &sif
}
if jsnCfg.Prefix_indexed_fields != nil {
pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
+ copy(pif, *jsnCfg.Prefix_indexed_fields)
st.PrefixIndexedFields = &pif
}
if jsnCfg.Suffix_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.Suffix_indexed_fields)
st.SuffixIndexedFields = &sif
}
if jsnCfg.Nested_fields != nil {
@@ -133,25 +127,19 @@ func (st *StatSCfg) AsMapInterface() (initialMP map[string]any) {
}
if st.StringIndexedFields != nil {
stringIndexedFields := make([]string, len(*st.StringIndexedFields))
- for i, item := range *st.StringIndexedFields {
- stringIndexedFields[i] = item
- }
+ copy(stringIndexedFields, *st.StringIndexedFields)
initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
}
if st.PrefixIndexedFields != nil {
prefixIndexedFields := make([]string, len(*st.PrefixIndexedFields))
- for i, item := range *st.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
+ copy(prefixIndexedFields, *st.PrefixIndexedFields)
initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
}
if st.SuffixIndexedFields != nil {
suffixIndexedFields := make([]string, len(*st.SuffixIndexedFields))
- for i, item := range *st.SuffixIndexedFields {
- suffixIndexedFields[i] = item
- }
+ copy(suffixIndexedFields, *st.SuffixIndexedFields)
initialMP[utils.SuffixIndexedFieldsCfg] = suffixIndexedFields
}
@@ -187,30 +175,22 @@ func (st StatSCfg) Clone() (cln *StatSCfg) {
}
if st.ThresholdSConns != nil {
cln.ThresholdSConns = make([]string, len(st.ThresholdSConns))
- for i, con := range st.ThresholdSConns {
- cln.ThresholdSConns[i] = con
- }
+ copy(cln.ThresholdSConns, st.ThresholdSConns)
}
if st.StringIndexedFields != nil {
idx := make([]string, len(*st.StringIndexedFields))
- for i, dx := range *st.StringIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *st.StringIndexedFields)
cln.StringIndexedFields = &idx
}
if st.PrefixIndexedFields != nil {
idx := make([]string, len(*st.PrefixIndexedFields))
- for i, dx := range *st.PrefixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *st.PrefixIndexedFields)
cln.PrefixIndexedFields = &idx
}
if st.SuffixIndexedFields != nil {
idx := make([]string, len(*st.SuffixIndexedFields))
- for i, dx := range *st.SuffixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *st.SuffixIndexedFields)
cln.SuffixIndexedFields = &idx
}
return
diff --git a/config/stordbcfg.go b/config/stordbcfg.go
index f2f316078..aaef51a62 100644
--- a/config/stordbcfg.go
+++ b/config/stordbcfg.go
@@ -186,27 +186,19 @@ func (dbcfg *StorDbCfg) Clone() (cln *StorDbCfg) {
}
if dbcfg.StringIndexedFields != nil {
cln.StringIndexedFields = make([]string, len(dbcfg.StringIndexedFields))
- for i, idx := range dbcfg.StringIndexedFields {
- cln.StringIndexedFields[i] = idx
- }
+ copy(cln.StringIndexedFields, dbcfg.StringIndexedFields)
}
if dbcfg.PrefixIndexedFields != nil {
cln.PrefixIndexedFields = make([]string, len(dbcfg.PrefixIndexedFields))
- for i, idx := range dbcfg.PrefixIndexedFields {
- cln.PrefixIndexedFields[i] = idx
- }
+ copy(cln.PrefixIndexedFields, dbcfg.PrefixIndexedFields)
}
if dbcfg.RmtConns != nil {
cln.RmtConns = make([]string, len(dbcfg.RmtConns))
- for i, conn := range dbcfg.RmtConns {
- cln.RmtConns[i] = conn
- }
+ copy(cln.RmtConns, dbcfg.RmtConns)
}
if dbcfg.RplConns != nil {
cln.RplConns = make([]string, len(dbcfg.RplConns))
- for i, conn := range dbcfg.RplConns {
- cln.RplConns[i] = conn
- }
+ copy(cln.RplConns, dbcfg.RplConns)
}
return
}
diff --git a/config/stordbcfg_test.go b/config/stordbcfg_test.go
index b57e93a6b..0b14ebe2b 100644
--- a/config/stordbcfg_test.go
+++ b/config/stordbcfg_test.go
@@ -100,24 +100,6 @@ func TestStoreDbCfgloadFromJsonCfgCase1(t *testing.T) {
t.Errorf("Expected %+v \n, recevied %+v", utils.ToJSON(expected.RmtConns), utils.ToJSON(jsonCfg.storDbCfg.RmtConns))
}
- if err := jsonCfg.storDbCfg.Opts.loadFromJSONCfg(nil); err != nil {
- t.Error(err)
- } else if err := jsonCfg.storDbCfg.Opts.loadFromJSONCfg(&DBOptsJson{
- SQLConnMaxLifetime: utils.StringPointer("test1"),
- }); err == nil {
- t.Error(err)
- } else if err := jsonCfg.storDbCfg.Opts.loadFromJSONCfg(&DBOptsJson{
- MongoQueryTimeout: utils.StringPointer("test2"),
- }); err == nil {
- t.Error(err)
- } else if err := jsonCfg.storDbCfg.loadFromJSONCfg(&DbJsonCfg{
- Items: &map[string]*ItemOptJson{
- utils.MetaSessionsCosts: {
- Ttl: utils.StringPointer("test3"),
- },
- }}); err == nil {
-
- }
}
func TestStoreDbCfgloadFromJsonCfgCase2(t *testing.T) {
diff --git a/config/thresholdscfg.go b/config/thresholdscfg.go
index fac78c71d..f99a21f9d 100644
--- a/config/thresholdscfg.go
+++ b/config/thresholdscfg.go
@@ -71,23 +71,17 @@ func (t *ThresholdSCfg) loadFromJSONCfg(jsnCfg *ThresholdSJsonCfg) (err error) {
}
if jsnCfg.String_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.String_indexed_fields))
- for i, fID := range *jsnCfg.String_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.String_indexed_fields)
t.StringIndexedFields = &sif
}
if jsnCfg.Prefix_indexed_fields != nil {
pif := make([]string, len(*jsnCfg.Prefix_indexed_fields))
- for i, fID := range *jsnCfg.Prefix_indexed_fields {
- pif[i] = fID
- }
+ copy(pif, *jsnCfg.Prefix_indexed_fields)
t.PrefixIndexedFields = &pif
}
if jsnCfg.Suffix_indexed_fields != nil {
sif := make([]string, len(*jsnCfg.Suffix_indexed_fields))
- for i, fID := range *jsnCfg.Suffix_indexed_fields {
- sif[i] = fID
- }
+ copy(sif, *jsnCfg.Suffix_indexed_fields)
t.SuffixIndexedFields = &sif
}
if jsnCfg.Nested_fields != nil {
@@ -118,23 +112,17 @@ func (t *ThresholdSCfg) AsMapInterface() (initialMP map[string]any) {
if t.StringIndexedFields != nil {
stringIndexedFields := make([]string, len(*t.StringIndexedFields))
- for i, item := range *t.StringIndexedFields {
- stringIndexedFields[i] = item
- }
+ copy(stringIndexedFields, *t.StringIndexedFields)
initialMP[utils.StringIndexedFieldsCfg] = stringIndexedFields
}
if t.PrefixIndexedFields != nil {
prefixIndexedFields := make([]string, len(*t.PrefixIndexedFields))
- for i, item := range *t.PrefixIndexedFields {
- prefixIndexedFields[i] = item
- }
+ copy(prefixIndexedFields, *t.PrefixIndexedFields)
initialMP[utils.PrefixIndexedFieldsCfg] = prefixIndexedFields
}
if t.SuffixIndexedFields != nil {
suffixIndexedFields := make([]string, len(*t.SuffixIndexedFields))
- for i, item := range *t.SuffixIndexedFields {
- suffixIndexedFields[i] = item
- }
+ copy(suffixIndexedFields, *t.SuffixIndexedFields)
initialMP[utils.SuffixIndexedFieldsCfg] = suffixIndexedFields
}
return
@@ -159,23 +147,17 @@ func (t ThresholdSCfg) Clone() (cln *ThresholdSCfg) {
if t.StringIndexedFields != nil {
idx := make([]string, len(*t.StringIndexedFields))
- for i, dx := range *t.StringIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *t.StringIndexedFields)
cln.StringIndexedFields = &idx
}
if t.PrefixIndexedFields != nil {
idx := make([]string, len(*t.PrefixIndexedFields))
- for i, dx := range *t.PrefixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *t.PrefixIndexedFields)
cln.PrefixIndexedFields = &idx
}
if t.SuffixIndexedFields != nil {
idx := make([]string, len(*t.SuffixIndexedFields))
- for i, dx := range *t.SuffixIndexedFields {
- idx[i] = dx
- }
+ copy(idx, *t.SuffixIndexedFields)
cln.SuffixIndexedFields = &idx
}
return
diff --git a/cores/basic_auth.go b/cores/basic_auth.go
index 21ba89c1e..31bf342aa 100644
--- a/cores/basic_auth.go
+++ b/cores/basic_auth.go
@@ -55,28 +55,28 @@ func basicAuth(userList map[string]string) basicAuthMiddleware {
authHeader := strings.SplitN(r.Header.Get("Authorization"), " ", 2)
if len(authHeader) != 2 {
utils.Logger.Warning(" Missing authorization header value")
- http.Error(w, "Not authorized", 401)
+ http.Error(w, "Not authorized", http.StatusUnauthorized)
return
}
authHeaderDecoded, err := base64.StdEncoding.DecodeString(authHeader[1])
if err != nil {
utils.Logger.Warning(" Unable to decode authorization header")
- http.Error(w, err.Error(), 401)
+ http.Error(w, err.Error(), http.StatusUnauthorized)
return
}
userPass := strings.SplitN(string(authHeaderDecoded), ":", 2)
if len(userPass) != 2 {
utils.Logger.Warning(" Unauthorized API access. Missing or extra credential components")
- http.Error(w, "Not authorized", 401)
+ http.Error(w, "Not authorized", http.StatusUnauthorized)
return
}
valid := verifyCredential(userPass[0], userPass[1], userList)
if !valid {
utils.Logger.Warning(fmt.Sprintf(" Unauthorized API access by user '%s'", userPass[0]))
- http.Error(w, "Not authorized", 401)
+ http.Error(w, "Not authorized", http.StatusUnauthorized)
return
}
diff --git a/cores/core.go b/cores/core.go
index 6913fda3d..cda07e0f8 100644
--- a/cores/core.go
+++ b/cores/core.go
@@ -68,7 +68,6 @@ func (cS *CoreService) Shutdown() {
utils.Logger.Info(fmt.Sprintf("<%s> shutdown initialized", utils.CoreS))
cS.StopChanMemProf()
utils.Logger.Info(fmt.Sprintf("<%s> shutdown complete", utils.CoreS))
- return
}
// StopChanMemProf will stop the MemoryProfiling Channel in order to create
diff --git a/cores/server.go b/cores/server.go
index 3700ba59a..79bec3b99 100644
--- a/cores/server.go
+++ b/cores/server.go
@@ -244,7 +244,7 @@ func (s *Server) ServeHTTP(addr string, jsonRPCURL string, wsRPCURL string,
}
utils.Logger.Info(fmt.Sprintf(" start listening at <%s>", addr))
if err := http.ListenAndServe(addr, s.httpMux); err != nil {
- log.Println(fmt.Sprintf("Error: %s when listening ", err))
+ log.Printf("Error: %s when listening ", err)
shdChan.CloseOnce()
}
}
@@ -379,7 +379,7 @@ func loadTLSConfig(serverCrt, serverKey, caCert string, serverPolicy int,
}
if ok := rootCAs.AppendCertsFromPEM(ca); !ok {
- utils.Logger.Crit(fmt.Sprintf("Cannot append certificate authority"))
+ utils.Logger.Crit("Cannot append certificate authority")
return config, errors.New("Cannot append certificate authority")
}
}
@@ -411,7 +411,7 @@ func (s *Server) serveCodecTLS(addr, codecName, serverCrt, serverKey, caCert str
}
listener, err := tls.Listen(utils.TCP, addr, config)
if err != nil {
- log.Println(fmt.Sprintf("Error: %s when listening", err))
+ log.Printf("Error: %s when listening", err)
shdChan.CloseOnce()
return
}
@@ -483,7 +483,7 @@ func (s *Server) ServeHTTPTLS(addr, serverCrt, serverKey, caCert string, serverP
}
utils.Logger.Info(fmt.Sprintf(" start listening at <%s>", addr))
if err := httpSrv.ListenAndServeTLS(serverCrt, serverKey); err != nil {
- log.Println(fmt.Sprintf("Error: %s when listening ", err))
+ log.Printf("Error: %s when listening ", err)
shdChan.CloseOnce()
}
}
diff --git a/dispatchers/dispatchers_test.go b/dispatchers/dispatchers_test.go
index 715dae2ae..bb9062b15 100644
--- a/dispatchers/dispatchers_test.go
+++ b/dispatchers/dispatchers_test.go
@@ -1218,7 +1218,7 @@ func TestDispatcherServiceDispatchDspErrHostNotFound3(t *testing.T) {
engine.Cache = cacheInit
}
-func (dS *DispatcherService) DispatcherServiceTest(ev *utils.CGREvent, reply *string) (error, any) {
+func (dS *DispatcherService) DispatcherServiceTest(ev *utils.CGREvent, reply *string) (any, error) {
*reply = utils.Pong
return nil, nil
}
diff --git a/dispatchers/libdispatcher_test.go b/dispatchers/libdispatcher_test.go
index f16e9f2c1..4e5e2efeb 100644
--- a/dispatchers/libdispatcher_test.go
+++ b/dispatchers/libdispatcher_test.go
@@ -562,12 +562,6 @@ func TestLibDispatcherSingleResultDispatcherCastError(t *testing.T) {
engine.Cache = cacheInit
}
-type mockTypeCon struct{}
-
-func (*mockTypeCon) Call(serviceMethod string, args, reply any) error {
- return utils.ErrNotFound
-}
-
func TestLibDispatcherBroadcastDispatcherDispatchError1(t *testing.T) {
cacheInit := engine.Cache
cfg := config.NewDefaultCGRConfig()
diff --git a/ees/ees_test.go b/ees/ees_test.go
index 2fe6833ef..82bab57aa 100644
--- a/ees/ees_test.go
+++ b/ees/ees_test.go
@@ -56,7 +56,6 @@ func TestListenAndServe(t *testing.T) {
cfgRld := make(chan struct{}, 1)
cfgRld <- struct{}{}
go func() {
- time.Sleep(10)
stopChan <- struct{}{}
}()
var err error
diff --git a/ees/httpjsonmap_test.go b/ees/httpjsonmap_test.go
index 20fd38b8d..10f5864e9 100644
--- a/ees/httpjsonmap_test.go
+++ b/ees/httpjsonmap_test.go
@@ -211,6 +211,9 @@ func TestHTTPJsonMapPrepareMap(t *testing.T) {
t.Error(err)
}
body, err := json.Marshal(valMp)
+ if err != nil {
+ t.Error(err)
+ }
exp := &HTTPPosterRequest{
Header: httpEE.hdr,
Body: body,
diff --git a/engine/balance_filter.go b/engine/balance_filter.go
index 220e6a082..83eaf26e4 100644
--- a/engine/balance_filter.go
+++ b/engine/balance_filter.go
@@ -230,9 +230,8 @@ func (bf *BalanceFilter) LoadFromBalance(b *Balance) *BalanceFilter {
}
if len(b.Timings) != 0 {
bf.Timings = make([]*RITiming, len(b.Timings))
- for i, timing := range b.Timings {
- bf.Timings[i] = timing
- }
+ copy(bf.Timings, b.Timings)
+
}
if len(b.Factor) != 0 {
bf.Factor = &b.Factor
@@ -404,9 +403,7 @@ func (bf *BalanceFilter) ModifyBalance(b *Balance) {
}
if bf.Timings != nil && len(bf.Timings) != 0 {
b.Timings = make([]*RITiming, len(bf.Timings))
- for i, timing := range bf.Timings {
- b.Timings[i] = timing
- }
+ copy(b.Timings, bf.Timings)
}
if bf.Weight != nil {
b.Weight = *bf.Weight
diff --git a/engine/cdrs.go b/engine/cdrs.go
index 2a927cffc..e35065e42 100644
--- a/engine/cdrs.go
+++ b/engine/cdrs.go
@@ -759,9 +759,8 @@ func (attr *ArgV1ProcessEvent) Clone() *ArgV1ProcessEvent {
var flags []string
if attr.Flags != nil {
flags = make([]string, len(attr.Flags))
- for i, id := range attr.Flags {
- flags[i] = id
- }
+ copy(flags, attr.Flags)
+
}
return &ArgV1ProcessEvent{
Flags: flags,
diff --git a/engine/dispatcherprfl.go b/engine/dispatcherprfl.go
index d9bb9a261..4b2bd6ba0 100644
--- a/engine/dispatcherprfl.go
+++ b/engine/dispatcherprfl.go
@@ -44,9 +44,7 @@ func (dC *DispatcherHostProfile) Clone() (cln *DispatcherHostProfile) {
}
if dC.FilterIDs != nil {
cln.FilterIDs = make([]string, len(dC.FilterIDs))
- for i, fltr := range dC.FilterIDs {
- cln.FilterIDs[i] = fltr
- }
+ copy(cln.FilterIDs, dC.FilterIDs)
}
if dC.Params != nil {
cln.Params = make(map[string]any)
@@ -194,8 +192,6 @@ func (dHPrflIDs DispatcherHostIDs) Shuffle() {
func (dHPrflIDs DispatcherHostIDs) Clone() (cln DispatcherHostIDs) {
cln = make(DispatcherHostIDs, len(dHPrflIDs))
- for i, dhID := range dHPrflIDs {
- cln[i] = dhID
- }
+ copy(cln, dHPrflIDs)
return
}
diff --git a/engine/exportrequest_test.go b/engine/exportrequest_test.go
index b04b760c2..701360a4e 100644
--- a/engine/exportrequest_test.go
+++ b/engine/exportrequest_test.go
@@ -589,7 +589,7 @@ func TestExportRequestSetFields(t *testing.T) {
Path: "<*uch;*opts>",
},
}
- if err = eeR.SetFields(fctTemp); err == nil || err.Error() != fmt.Sprint("unsupported field prefix: <*uch*opts> when set field") {
+ if err = eeR.SetFields(fctTemp); err == nil || err.Error() != "unsupported field prefix: <*uch*opts> when set field" {
t.Error(err)
}
}
diff --git a/engine/libeventcost.go b/engine/libeventcost.go
index b68d9c963..77544200f 100644
--- a/engine/libeventcost.go
+++ b/engine/libeventcost.go
@@ -383,7 +383,7 @@ type RatingFilters map[string]RatingMatchedFilters // so we can define search me
// GetIDWithSet attempts to retrieve the UUID of a matching data or create a new one
func (rfs RatingFilters) GetIDWithSet(rmf RatingMatchedFilters) string {
- if rmf == nil || len(rmf) == 0 {
+ if len(rmf) == 0 {
return ""
}
for k, v := range rfs {
@@ -495,7 +495,7 @@ func (crs ChargedRates) FieldAsInterface(fldPath []string) (val any, err error)
// GetIDWithSet attempts to retrieve the UUID of a matching data or create a new one
func (crs ChargedRates) GetIDWithSet(rg RateGroups) string {
- if rg == nil || len(rg) == 0 {
+ if len(rg) == 0 {
return ""
}
for k, v := range crs {
diff --git a/engine/libindex.go b/engine/libindex.go
index 8efdce5d7..a13bafc31 100644
--- a/engine/libindex.go
+++ b/engine/libindex.go
@@ -632,9 +632,8 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
return nil, e
}
fltrIDs := make([]string, len(th.FilterIDs))
- for i, fltrID := range th.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, th.FilterIDs)
+
return &fltrIDs, nil
}, newFlt); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -652,9 +651,7 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
return nil, e
}
fltrIDs := make([]string, len(sq.FilterIDs))
- for i, fltrID := range sq.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, sq.FilterIDs)
return &fltrIDs, nil
}, newFlt); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -672,9 +669,7 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
return nil, e
}
fltrIDs := make([]string, len(rs.FilterIDs))
- for i, fltrID := range rs.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, rs.FilterIDs)
return &fltrIDs, nil
}, newFlt); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -692,9 +687,7 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
return nil, e
}
fltrIDs := make([]string, len(rt.FilterIDs))
- for i, fltrID := range rt.FilterIDs {
- fltrIDs[i] = fltrID
- }
+ copy(fltrIDs, rt.FilterIDs)
return &fltrIDs, nil
}, newFlt); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
@@ -712,9 +705,9 @@ func UpdateFilterIndex(dm *DataManager, oldFlt, newFlt *Filter) (err error) {
return nil, e
}
fltrIDs := make([]string, len(ch.FilterIDs))
- for i, fltrID := range ch.FilterIDs {
- fltrIDs[i] = fltrID
- }
+
+ copy(fltrIDs, ch.FilterIDs)
+
return &fltrIDs, nil
}, newFlt); err != nil && err != utils.ErrNotFound {
return utils.APIErrorHandler(err)
diff --git a/engine/libstats.go b/engine/libstats.go
index b5c1d4ad1..fdd79b9af 100644
--- a/engine/libstats.go
+++ b/engine/libstats.go
@@ -103,9 +103,9 @@ func NewStoredStatQueue(sq *StatQueue, ms Marshaler) (sSQ *StoredStatQueue, err
SQItems: make([]SQItem, len(sq.SQItems)),
SQMetrics: make(map[string][]byte, len(sq.SQMetrics)),
}
- for i, sqItm := range sq.SQItems {
- sSQ.SQItems[i] = sqItm
- }
+
+ copy(sSQ.SQItems, sq.SQItems)
+
for metricID, metric := range sq.SQMetrics {
marshaled, err := metric.Marshal(ms)
if err != nil {
@@ -146,9 +146,9 @@ func (ssq *StoredStatQueue) AsStatQueue(ms Marshaler) (sq *StatQueue, err error)
SQItems: make([]SQItem, len(ssq.SQItems)),
SQMetrics: make(map[string]StatMetric, len(ssq.SQMetrics)),
}
- for i, sqItm := range ssq.SQItems {
- sq.SQItems[i] = sqItm
- }
+
+ copy(sq.SQItems, ssq.SQItems)
+
for metricID, marshaled := range ssq.SQMetrics {
if metric, err := NewStatMetric(metricID, 0, []string{}); err != nil {
return nil, err
diff --git a/engine/model_helpers.go b/engine/model_helpers.go
index 646573ad5..bc78e3daf 100644
--- a/engine/model_helpers.go
+++ b/engine/model_helpers.go
@@ -1180,12 +1180,10 @@ func APItoResource(tpRL *utils.TPResourceProfile, timezone string) (rp *Resource
return nil, err
}
}
- for i, fltr := range tpRL.FilterIDs {
- rp.FilterIDs[i] = fltr
- }
- for i, th := range tpRL.ThresholdIDs {
- rp.ThresholdIDs[i] = th
- }
+
+ copy(rp.FilterIDs, tpRL.FilterIDs)
+ copy(rp.ThresholdIDs, tpRL.ThresholdIDs)
+
if tpRL.ActivationInterval != nil {
if rp.ActivationInterval, err = tpRL.ActivationInterval.AsActivationInterval(timezone); err != nil {
return nil, err
@@ -1215,12 +1213,9 @@ func ResourceProfileToAPI(rp *ResourceProfile) (tpRL *utils.TPResourceProfile) {
if rp.UsageTTL != time.Duration(0) {
tpRL.UsageTTL = rp.UsageTTL.String()
}
- for i, fli := range rp.FilterIDs {
- tpRL.FilterIDs[i] = fli
- }
- for i, fli := range rp.ThresholdIDs {
- tpRL.ThresholdIDs[i] = fli
- }
+
+ copy(tpRL.FilterIDs, rp.FilterIDs)
+ copy(tpRL.ThresholdIDs, rp.ThresholdIDs)
if rp.ActivationInterval != nil {
if !rp.ActivationInterval.ActivationTime.IsZero() {
@@ -1411,12 +1406,10 @@ func APItoStats(tpST *utils.TPStatProfile, timezone string) (st *StatQueueProfil
FilterIDs: metric.FilterIDs,
}
}
- for i, trh := range tpST.ThresholdIDs {
- st.ThresholdIDs[i] = trh
- }
- for i, fltr := range tpST.FilterIDs {
- st.FilterIDs[i] = fltr
- }
+
+ copy(st.ThresholdIDs, tpST.ThresholdIDs)
+ copy(st.FilterIDs, tpST.FilterIDs)
+
if tpST.ActivationInterval != nil {
if st.ActivationInterval, err = tpST.ActivationInterval.AsActivationInterval(timezone); err != nil {
return nil, err
@@ -1445,21 +1438,16 @@ func StatQueueProfileToAPI(st *StatQueueProfile) (tpST *utils.TPStatProfile) {
}
if len(metric.FilterIDs) != 0 {
tpST.Metrics[i].FilterIDs = make([]string, len(metric.FilterIDs))
- for j, fltr := range metric.FilterIDs {
- tpST.Metrics[i].FilterIDs[j] = fltr
- }
+ copy(tpST.Metrics[i].FilterIDs, metric.FilterIDs)
+
}
}
if st.TTL != time.Duration(0) {
tpST.TTL = st.TTL.String()
}
- for i, fli := range st.FilterIDs {
- tpST.FilterIDs[i] = fli
- }
- for i, fli := range st.ThresholdIDs {
- tpST.ThresholdIDs[i] = fli
- }
+ copy(tpST.FilterIDs, st.FilterIDs)
+ copy(tpST.ThresholdIDs, st.ThresholdIDs)
if st.ActivationInterval != nil {
if !st.ActivationInterval.ActivationTime.IsZero() {
@@ -1634,13 +1622,10 @@ func APItoThresholdProfile(tpTH *utils.TPThresholdProfile, timezone string) (th
return nil, err
}
}
- for i, ati := range tpTH.ActionIDs {
- th.ActionIDs[i] = ati
- }
- for i, fli := range tpTH.FilterIDs {
- th.FilterIDs[i] = fli
- }
+ copy(th.ActionIDs, tpTH.ActionIDs)
+ copy(th.FilterIDs, tpTH.FilterIDs)
+
if tpTH.ActivationInterval != nil {
if th.ActivationInterval, err = tpTH.ActivationInterval.AsActivationInterval(timezone); err != nil {
return nil, err
@@ -1665,12 +1650,9 @@ func ThresholdProfileToAPI(th *ThresholdProfile) (tpTH *utils.TPThresholdProfile
if th.MinSleep != time.Duration(0) {
tpTH.MinSleep = th.MinSleep.String()
}
- for i, fli := range th.FilterIDs {
- tpTH.FilterIDs[i] = fli
- }
- for i, fli := range th.ActionIDs {
- tpTH.ActionIDs[i] = fli
- }
+
+ copy(tpTH.FilterIDs, th.FilterIDs)
+ copy(tpTH.ActionIDs, th.ActionIDs)
if th.ActivationInterval != nil {
if !th.ActivationInterval.ActivationTime.IsZero() {
@@ -1808,9 +1790,9 @@ func FilterToTPFilter(f *Filter) (tpFltr *utils.TPFilterProfile) {
Element: reqFltr.Element,
Values: make([]string, len(reqFltr.Values)),
}
- for j, val := range reqFltr.Values {
- tpFltr.Filters[i].Values[j] = val
- }
+
+ copy(tpFltr.Filters[i].Values, reqFltr.Values)
+
}
if f.ActivationInterval != nil {
tpFltr.ActivationInterval = &utils.TPActivationInterval{
@@ -2016,12 +1998,10 @@ func APItoRouteProfile(tpRp *utils.TPRouteProfile, timezone string) (rp *RoutePr
SortingParameters: make([]string, len(tpRp.SortingParameters)),
FilterIDs: make([]string, len(tpRp.FilterIDs)),
}
- for i, stp := range tpRp.SortingParameters {
- rp.SortingParameters[i] = stp
- }
- for i, fli := range tpRp.FilterIDs {
- rp.FilterIDs[i] = fli
- }
+
+ copy(rp.SortingParameters, tpRp.SortingParameters)
+ copy(rp.FilterIDs, tpRp.FilterIDs)
+
if tpRp.ActivationInterval != nil {
if rp.ActivationInterval, err = tpRp.ActivationInterval.AsActivationInterval(timezone); err != nil {
return nil, err
@@ -2068,12 +2048,10 @@ func RouteProfileToAPI(rp *RouteProfile) (tpRp *utils.TPRouteProfile) {
RouteParameters: route.RouteParameters,
}
}
- for i, fli := range rp.FilterIDs {
- tpRp.FilterIDs[i] = fli
- }
- for i, fli := range rp.SortingParameters {
- tpRp.SortingParameters[i] = fli
- }
+
+ copy(tpRp.FilterIDs, rp.FilterIDs)
+ copy(tpRp.SortingParameters, rp.SortingParameters)
+
if rp.ActivationInterval != nil {
if !rp.ActivationInterval.ActivationTime.IsZero() {
tpRp.ActivationInterval.ActivationTime = rp.ActivationInterval.ActivationTime.Format(time.RFC3339)
@@ -2214,12 +2192,10 @@ func APItoAttributeProfile(tpAttr *utils.TPAttributeProfile, timezone string) (a
Contexts: make([]string, len(tpAttr.Contexts)),
Attributes: make([]*Attribute, len(tpAttr.Attributes)),
}
- for i, fli := range tpAttr.FilterIDs {
- attrPrf.FilterIDs[i] = fli
- }
- for i, context := range tpAttr.Contexts {
- attrPrf.Contexts[i] = context
- }
+
+ copy(attrPrf.FilterIDs, tpAttr.FilterIDs)
+ copy(attrPrf.Contexts, tpAttr.Contexts)
+
for i, reqAttr := range tpAttr.Attributes {
if reqAttr.Path == utils.EmptyString { // we do not suppot empty Path in Attributes
err = fmt.Errorf("empty path in AttributeProfile <%s>", attrPrf.TenantID())
@@ -2255,12 +2231,10 @@ func AttributeProfileToAPI(attrPrf *AttributeProfile) (tpAttr *utils.TPAttribute
Blocker: attrPrf.Blocker,
Weight: attrPrf.Weight,
}
- for i, fli := range attrPrf.FilterIDs {
- tpAttr.FilterIDs[i] = fli
- }
- for i, fli := range attrPrf.Contexts {
- tpAttr.Contexts[i] = fli
- }
+
+ copy(tpAttr.FilterIDs, attrPrf.FilterIDs)
+ copy(tpAttr.Contexts, attrPrf.Contexts)
+
for i, attr := range attrPrf.Attributes {
tpAttr.Attributes[i] = &utils.TPAttribute{
FilterIDs: attr.FilterIDs,
@@ -2454,12 +2428,10 @@ func APItoChargerProfile(tpCPP *utils.TPChargerProfile, timezone string) (cpp *C
FilterIDs: make([]string, len(tpCPP.FilterIDs)),
AttributeIDs: make([]string, len(tpCPP.AttributeIDs)),
}
- for i, fli := range tpCPP.FilterIDs {
- cpp.FilterIDs[i] = fli
- }
- for i, attribute := range tpCPP.AttributeIDs {
- cpp.AttributeIDs[i] = attribute
- }
+
+ copy(cpp.FilterIDs, tpCPP.FilterIDs)
+ copy(cpp.AttributeIDs, tpCPP.AttributeIDs)
+
if tpCPP.ActivationInterval != nil {
if cpp.ActivationInterval, err = tpCPP.ActivationInterval.AsActivationInterval(timezone); err != nil {
return nil, err
@@ -2478,12 +2450,10 @@ func ChargerProfileToAPI(chargerPrf *ChargerProfile) (tpCharger *utils.TPCharger
AttributeIDs: make([]string, len(chargerPrf.AttributeIDs)),
Weight: chargerPrf.Weight,
}
- for i, fli := range chargerPrf.FilterIDs {
- tpCharger.FilterIDs[i] = fli
- }
- for i, fli := range chargerPrf.AttributeIDs {
- tpCharger.AttributeIDs[i] = fli
- }
+
+ copy(tpCharger.FilterIDs, chargerPrf.FilterIDs)
+ copy(tpCharger.AttributeIDs, chargerPrf.AttributeIDs)
+
if chargerPrf.ActivationInterval != nil {
if !chargerPrf.ActivationInterval.ActivationTime.IsZero() {
tpCharger.ActivationInterval.ActivationTime = chargerPrf.ActivationInterval.ActivationTime.Format(time.RFC3339)
@@ -2698,12 +2668,10 @@ func APItoDispatcherProfile(tpDPP *utils.TPDispatcherProfile, timezone string) (
StrategyParams: make(map[string]any),
Hosts: make(DispatcherHostProfiles, len(tpDPP.Hosts)),
}
- for i, fli := range tpDPP.FilterIDs {
- dpp.FilterIDs[i] = fli
- }
- for i, sub := range tpDPP.Subsystems {
- dpp.Subsystems[i] = sub
- }
+ copy(dpp.FilterIDs, tpDPP.FilterIDs)
+
+ copy(dpp.Subsystems, tpDPP.Subsystems)
+
for i, param := range tpDPP.StrategyParams {
if param != utils.EmptyString {
dpp.StrategyParams[strconv.Itoa(i)] = param
@@ -2717,9 +2685,9 @@ func APItoDispatcherProfile(tpDPP *utils.TPDispatcherProfile, timezone string) (
FilterIDs: make([]string, len(conn.FilterIDs)),
Params: make(map[string]any),
}
- for j, fltr := range conn.FilterIDs {
- dpp.Hosts[i].FilterIDs[j] = fltr
- }
+
+ copy(dpp.Hosts[i].FilterIDs, conn.FilterIDs)
+
for j, param := range conn.Params {
if param == utils.EmptyString {
continue
@@ -2753,12 +2721,9 @@ func DispatcherProfileToAPI(dpp *DispatcherProfile) (tpDPP *utils.TPDispatcherPr
Hosts: make([]*utils.TPDispatcherHostProfile, len(dpp.Hosts)),
}
- for i, fli := range dpp.FilterIDs {
- tpDPP.FilterIDs[i] = fli
- }
- for i, sub := range dpp.Subsystems {
- tpDPP.Subsystems[i] = sub
- }
+ copy(tpDPP.FilterIDs, dpp.FilterIDs)
+ copy(tpDPP.Subsystems, dpp.Subsystems)
+
for key, val := range dpp.StrategyParams {
// here we expect that the key to be an integer because
// according to APItoDispatcherProfile when we convert from TP to obj we use index as key
@@ -2774,9 +2739,8 @@ func DispatcherProfileToAPI(dpp *DispatcherProfile) (tpDPP *utils.TPDispatcherPr
Params: make([]any, len(host.Params)),
Blocker: host.Blocker,
}
- for j, fltr := range host.FilterIDs {
- tpDPP.Hosts[i].FilterIDs[j] = fltr
- }
+ copy(tpDPP.Hosts[i].FilterIDs, host.FilterIDs)
+
idx := 0
for key, val := range host.Params {
paramVal := val
diff --git a/engine/rateinterval.go b/engine/rateinterval.go
index 650d2b2eb..14e468c78 100644
--- a/engine/rateinterval.go
+++ b/engine/rateinterval.go
@@ -469,27 +469,20 @@ func (rit *RITiming) Clone() (cln *RITiming) {
}
if len(rit.Years) != 0 {
cln.Years = make(utils.Years, len(rit.Years))
- for i, year := range rit.Years {
- cln.Years[i] = year
- }
+ copy(cln.Years, rit.Years)
}
if len(rit.Months) != 0 {
cln.Months = make(utils.Months, len(rit.Months))
- for i, month := range rit.Months {
- cln.Months[i] = month
- }
+ copy(cln.Months, rit.Months)
}
if len(rit.MonthDays) != 0 {
cln.MonthDays = make(utils.MonthDays, len(rit.MonthDays))
- for i, monthDay := range rit.MonthDays {
- cln.MonthDays[i] = monthDay
- }
+ copy(cln.MonthDays, rit.MonthDays)
+
}
if len(rit.WeekDays) != 0 {
cln.WeekDays = make(utils.WeekDays, len(rit.WeekDays))
- for i, weekDay := range rit.WeekDays {
- cln.WeekDays[i] = weekDay
- }
+ copy(cln.WeekDays, rit.WeekDays)
}
return
}
diff --git a/engine/storage_csv.go b/engine/storage_csv.go
index 2fb326e76..0f8b2a28b 100644
--- a/engine/storage_csv.go
+++ b/engine/storage_csv.go
@@ -36,6 +36,7 @@ import (
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
+ "google.golang.org/api/option"
"google.golang.org/api/sheets/v4"
)
@@ -804,7 +805,7 @@ func newSheet() (sht *sheets.Service, err error) { //*google_api
if err != nil {
return nil, err
}
- sht, err = sheets.New(client)
+ sht, err = sheets.NewService(context.Background(), option.WithHTTPClient(client))
if err != nil {
err = fmt.Errorf("Unable to retrieve Sheets client: %v", err)
}
diff --git a/guardian/guardian_test.go b/guardian/guardian_test.go
index e91676565..35d6ea0cf 100644
--- a/guardian/guardian_test.go
+++ b/guardian/guardian_test.go
@@ -49,7 +49,7 @@ func TestGuardianMultipleKeys(t *testing.T) {
}
sg.Wait()
mustExecDur := time.Duration(maxIter*100) * time.Millisecond
- if execTime := time.Now().Sub(tStart); execTime < mustExecDur ||
+ if execTime := time.Since(tStart); execTime < mustExecDur ||
execTime > mustExecDur+100*time.Millisecond {
t.Errorf("Execution took: %v", execTime)
}
@@ -78,7 +78,7 @@ func TestGuardianTimeout(t *testing.T) {
}
sg.Wait()
mustExecDur := time.Duration(maxIter*10) * time.Millisecond
- if execTime := time.Now().Sub(tStart); execTime < mustExecDur ||
+ if execTime := time.Since(tStart); execTime < mustExecDur ||
execTime > mustExecDur+100*time.Millisecond {
t.Errorf("Execution took: %v", execTime)
}
@@ -155,7 +155,7 @@ func TestGuardianGuardIDs(t *testing.T) {
// test lock without timer
refID := Guardian.GuardIDs("", 0, lockIDs...)
- if totalLockDur := time.Now().Sub(tStart); totalLockDur < lockDur {
+ if totalLockDur := time.Since(tStart); totalLockDur < lockDur {
t.Errorf("Lock duration too small")
}
time.Sleep(30 * time.Millisecond)
diff --git a/migrator/tp_account_actions.go b/migrator/tp_account_actions.go
index edf171ca1..60b595c4b 100644
--- a/migrator/tp_account_actions.go
+++ b/migrator/tp_account_actions.go
@@ -34,7 +34,7 @@ func (m *Migrator) migrateCurrentTPaccountAcction() (err error) {
return err
}
if accAct != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPAccountActions(accAct); err != nil {
return err
}
diff --git a/migrator/tp_action_plans.go b/migrator/tp_action_plans.go
index 59f756d8f..eac8dbd9c 100644
--- a/migrator/tp_action_plans.go
+++ b/migrator/tp_action_plans.go
@@ -40,7 +40,7 @@ func (m *Migrator) migrateCurrentTPactionplans() (err error) {
return err
}
if actPln != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPActionPlans(actPln); err != nil {
return err
}
diff --git a/migrator/tp_action_triggers.go b/migrator/tp_action_triggers.go
index c2c9382fe..cb84a3fad 100644
--- a/migrator/tp_action_triggers.go
+++ b/migrator/tp_action_triggers.go
@@ -39,7 +39,7 @@ func (m *Migrator) migrateCurrentTPactiontriggers() (err error) {
return err
}
if actTrg != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPActionTriggers(actTrg); err != nil {
return err
}
diff --git a/migrator/tp_actions.go b/migrator/tp_actions.go
index 0929d3101..4e9ffd9fa 100644
--- a/migrator/tp_actions.go
+++ b/migrator/tp_actions.go
@@ -39,7 +39,7 @@ func (m *Migrator) migrateCurrentTPactions() (err error) {
return err
}
if action != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPActions(action); err != nil {
return err
}
diff --git a/migrator/tp_destination_rates.go b/migrator/tp_destination_rates.go
index 52201546a..a9e4b9121 100644
--- a/migrator/tp_destination_rates.go
+++ b/migrator/tp_destination_rates.go
@@ -39,7 +39,7 @@ func (m *Migrator) migrateCurrentTPdestinationrates() (err error) {
return err
}
if destRate != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPDestinationRates(destRate); err != nil {
return err
}
diff --git a/migrator/tp_destinations.go b/migrator/tp_destinations.go
index 219a54f90..418298b78 100644
--- a/migrator/tp_destinations.go
+++ b/migrator/tp_destinations.go
@@ -39,7 +39,7 @@ func (m *Migrator) migrateCurrentTPDestinations() (err error) {
return err
}
if destinations != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPDestinations(destinations); err != nil {
return err
}
diff --git a/migrator/tp_rates.go b/migrator/tp_rates.go
index 370c21692..5d766b619 100644
--- a/migrator/tp_rates.go
+++ b/migrator/tp_rates.go
@@ -40,7 +40,7 @@ func (m *Migrator) migrateCurrentTPrates() (err error) {
return err
}
if rates != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPRates(rates); err != nil {
return err
}
diff --git a/migrator/tp_rating_plans.go b/migrator/tp_rating_plans.go
index 7b9b1cd02..c56a1348d 100644
--- a/migrator/tp_rating_plans.go
+++ b/migrator/tp_rating_plans.go
@@ -40,7 +40,7 @@ func (m *Migrator) migrateCurrentTPratingplans() (err error) {
return err
}
if ratingPlan != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPRatingPlans(ratingPlan); err != nil {
return err
}
diff --git a/migrator/tp_rating_profiles.go b/migrator/tp_rating_profiles.go
index 742319738..a427fef39 100644
--- a/migrator/tp_rating_profiles.go
+++ b/migrator/tp_rating_profiles.go
@@ -36,7 +36,7 @@ func (m *Migrator) migrateCurrentTPratingprofiles() (err error) {
return err
}
if ratingProfile != nil {
- if m.dryRun != true {
+ if !m.dryRun {
if err := m.storDBOut.StorDB().SetTPRatingProfiles(ratingProfile); err != nil {
return err
}
diff --git a/services/analyzers.go b/services/analyzers.go
index 3755b0568..897e4b34e 100644
--- a/services/analyzers.go
+++ b/services/analyzers.go
@@ -132,7 +132,7 @@ func (anz *AnalyzerService) Shutdown() (err error) {
func (anz *AnalyzerService) IsRunning() bool {
anz.RLock()
defer anz.RUnlock()
- return anz != nil && anz.anz != nil
+ return anz.anz != nil
}
// ServiceName returns the service name
diff --git a/services/apierv1.go b/services/apierv1.go
index 37308f2c0..626628ae5 100644
--- a/services/apierv1.go
+++ b/services/apierv1.go
@@ -170,7 +170,7 @@ func (apiService *APIerSv1Service) Shutdown() (err error) {
func (apiService *APIerSv1Service) IsRunning() bool {
apiService.RLock()
defer apiService.RUnlock()
- return apiService != nil && apiService.api != nil
+ return apiService.api != nil
}
// ServiceName returns the service name
diff --git a/services/apierv2.go b/services/apierv2.go
index 6272490db..4fe5969de 100644
--- a/services/apierv2.go
+++ b/services/apierv2.go
@@ -121,7 +121,7 @@ func (api *APIerSv2Service) Shutdown() (err error) {
func (api *APIerSv2Service) IsRunning() bool {
api.RLock()
defer api.RUnlock()
- return api != nil && api.api != nil
+ return api.api != nil
}
// ServiceName returns the service name
diff --git a/services/asteriskagent.go b/services/asteriskagent.go
index 9fd95b600..c84af7cd2 100644
--- a/services/asteriskagent.go
+++ b/services/asteriskagent.go
@@ -98,15 +98,14 @@ func (ast *AsteriskAgent) shutdown() {
ast.Lock()
close(ast.stopChan)
ast.smas = nil
- ast.Unlock()
- return // no shutdown for the momment
+ ast.Unlock() // no shutdown for the momment
}
// IsRunning returns if the service is running
func (ast *AsteriskAgent) IsRunning() bool {
ast.RLock()
defer ast.RUnlock()
- return ast != nil && ast.smas != nil
+ return ast.smas != nil
}
// ServiceName returns the service name
diff --git a/services/attributes.go b/services/attributes.go
index d3384b828..a9b9f6c87 100644
--- a/services/attributes.go
+++ b/services/attributes.go
@@ -118,7 +118,7 @@ func (attrS *AttributeService) Shutdown() (err error) {
func (attrS *AttributeService) IsRunning() bool {
attrS.RLock()
defer attrS.RUnlock()
- return attrS != nil && attrS.attrS != nil
+ return attrS.attrS != nil
}
// ServiceName returns the service name
diff --git a/services/cdrs.go b/services/cdrs.go
index 6720f9946..7890c9c17 100644
--- a/services/cdrs.go
+++ b/services/cdrs.go
@@ -138,7 +138,7 @@ func (cdrService *CDRServer) Shutdown() (err error) {
func (cdrService *CDRServer) IsRunning() bool {
cdrService.RLock()
defer cdrService.RUnlock()
- return cdrService != nil && cdrService.cdrS != nil
+ return cdrService.cdrS != nil
}
// ServiceName returns the service name
diff --git a/services/chargers.go b/services/chargers.go
index 385587eae..88036c584 100644
--- a/services/chargers.go
+++ b/services/chargers.go
@@ -118,7 +118,7 @@ func (chrS *ChargerService) Shutdown() (err error) {
func (chrS *ChargerService) IsRunning() bool {
chrS.RLock()
defer chrS.RUnlock()
- return chrS != nil && chrS.chrS != nil
+ return chrS.chrS != nil
}
// ServiceName returns the service name
diff --git a/services/cores.go b/services/cores.go
index 42d285d40..e5c42cd2f 100644
--- a/services/cores.go
+++ b/services/cores.go
@@ -112,7 +112,7 @@ func (cS *CoreService) Shutdown() (err error) {
func (cS *CoreService) IsRunning() bool {
cS.RLock()
defer cS.RUnlock()
- return cS != nil && cS.cS != nil
+ return cS.cS != nil
}
// ServiceName returns the service name
diff --git a/services/datadb.go b/services/datadb.go
index e30213da5..f76201f54 100644
--- a/services/datadb.go
+++ b/services/datadb.go
@@ -117,7 +117,7 @@ func (db *DataDBService) Shutdown() (err error) {
func (db *DataDBService) IsRunning() bool {
db.RLock()
defer db.RUnlock()
- return db != nil && db.dm != nil && db.dm.DataDB() != nil
+ return db.dm != nil && db.dm.DataDB() != nil
}
// ServiceName returns the service name
diff --git a/services/diameteragent.go b/services/diameteragent.go
index 145e1ff44..1d916602c 100644
--- a/services/diameteragent.go
+++ b/services/diameteragent.go
@@ -122,7 +122,7 @@ func (da *DiameterAgent) Shutdown() (err error) {
func (da *DiameterAgent) IsRunning() bool {
da.RLock()
defer da.RUnlock()
- return da != nil && da.da != nil
+ return da.da != nil
}
// ServiceName returns the service name
diff --git a/services/dispatchers.go b/services/dispatchers.go
index f5eb6e953..01a2fcf46 100644
--- a/services/dispatchers.go
+++ b/services/dispatchers.go
@@ -122,7 +122,7 @@ func (dspS *DispatcherService) Shutdown() (err error) {
func (dspS *DispatcherService) IsRunning() bool {
dspS.RLock()
defer dspS.RUnlock()
- return dspS != nil && dspS.dspS != nil
+ return dspS.dspS != nil
}
// ServiceName returns the service name
diff --git a/services/ees.go b/services/ees.go
index 699ff4964..f83f595c6 100644
--- a/services/ees.go
+++ b/services/ees.go
@@ -79,7 +79,7 @@ func (es *EventExporterService) ShouldRun() (should bool) {
func (es *EventExporterService) IsRunning() bool {
es.RLock()
defer es.RUnlock()
- return es != nil && es.eeS != nil
+ return es.eeS != nil
}
// Reload handles the change of config
diff --git a/services/ers.go b/services/ers.go
index 7f182293b..210a4e4d7 100644
--- a/services/ers.go
+++ b/services/ers.go
@@ -109,7 +109,7 @@ func (erS *EventReaderService) Shutdown() (err error) {
func (erS *EventReaderService) IsRunning() bool {
erS.RLock()
defer erS.RUnlock()
- return erS != nil && erS.ers != nil
+ return erS.ers != nil
}
// ServiceName returns the service name
diff --git a/services/freeswitchagent.go b/services/freeswitchagent.go
index 01c2d145f..59c1b4d22 100644
--- a/services/freeswitchagent.go
+++ b/services/freeswitchagent.go
@@ -111,7 +111,7 @@ func (fS *FreeswitchAgent) Shutdown() (err error) {
func (fS *FreeswitchAgent) IsRunning() bool {
fS.RLock()
defer fS.RUnlock()
- return fS != nil && fS.fS != nil
+ return fS.fS != nil
}
// ServiceName returns the service name
diff --git a/services/httpagent.go b/services/httpagent.go
index 4b66ad054..b493758dd 100644
--- a/services/httpagent.go
+++ b/services/httpagent.go
@@ -96,7 +96,7 @@ func (ha *HTTPAgent) Shutdown() (err error) {
func (ha *HTTPAgent) IsRunning() bool {
ha.RLock()
defer ha.RUnlock()
- return ha != nil && ha.started
+ return ha.started
}
// ServiceName returns the service name
diff --git a/services/kamailioagent.go b/services/kamailioagent.go
index 4e5ed0738..161a28921 100644
--- a/services/kamailioagent.go
+++ b/services/kamailioagent.go
@@ -117,7 +117,7 @@ func (kam *KamailioAgent) Shutdown() (err error) {
func (kam *KamailioAgent) IsRunning() bool {
kam.RLock()
defer kam.RUnlock()
- return kam != nil && kam.kam != nil
+ return kam.kam != nil
}
// ServiceName returns the service name
diff --git a/services/loaders.go b/services/loaders.go
index 2afa3ec49..fea2e845e 100644
--- a/services/loaders.go
+++ b/services/loaders.go
@@ -136,7 +136,7 @@ func (ldrs *LoaderService) Shutdown() (err error) {
func (ldrs *LoaderService) IsRunning() bool {
ldrs.RLock()
defer ldrs.RUnlock()
- return ldrs != nil && ldrs.ldrs != nil && ldrs.ldrs.Enabled()
+ return ldrs.ldrs != nil && ldrs.ldrs.Enabled()
}
// ServiceName returns the service name
diff --git a/services/radiusagent.go b/services/radiusagent.go
index d16690a0b..6f0f73550 100644
--- a/services/radiusagent.go
+++ b/services/radiusagent.go
@@ -123,7 +123,7 @@ func (rad *RadiusAgent) shutdown() {
func (rad *RadiusAgent) IsRunning() bool {
rad.RLock()
defer rad.RUnlock()
- return rad != nil && rad.rad != nil
+ return rad.rad != nil
}
// ServiceName returns the service name
diff --git a/services/rals.go b/services/rals.go
index a578f7a9a..f5c6cf1fa 100644
--- a/services/rals.go
+++ b/services/rals.go
@@ -122,7 +122,7 @@ func (rals *RalService) Shutdown() (err error) {
func (rals *RalService) IsRunning() bool {
rals.RLock()
defer rals.RUnlock()
- return rals != nil && rals.rals != nil
+ return rals.rals != nil
}
// ServiceName returns the service name
diff --git a/services/registrarc.go b/services/registrarc.go
index de947831a..3ea66e2ee 100644
--- a/services/registrarc.go
+++ b/services/registrarc.go
@@ -93,7 +93,7 @@ func (dspS *RegistrarCService) Shutdown() (err error) {
func (dspS *RegistrarCService) IsRunning() bool {
dspS.RLock()
defer dspS.RUnlock()
- return dspS != nil && dspS.dspS != nil
+ return dspS.dspS != nil
}
// ServiceName returns the service name
diff --git a/services/resources.go b/services/resources.go
index 43e4e5371..c4ecce863 100644
--- a/services/resources.go
+++ b/services/resources.go
@@ -122,7 +122,7 @@ func (reS *ResourceService) Shutdown() (err error) {
func (reS *ResourceService) IsRunning() bool {
reS.RLock()
defer reS.RUnlock()
- return reS != nil && reS.reS != nil
+ return reS.reS != nil
}
// ServiceName returns the service name
diff --git a/services/routes.go b/services/routes.go
index 829f44a65..a54ca67eb 100644
--- a/services/routes.go
+++ b/services/routes.go
@@ -117,7 +117,7 @@ func (routeS *RouteService) Shutdown() (err error) {
func (routeS *RouteService) IsRunning() bool {
routeS.RLock()
defer routeS.RUnlock()
- return routeS != nil && routeS.routeS != nil
+ return routeS.routeS != nil
}
// ServiceName returns the service name
diff --git a/services/schedulers.go b/services/schedulers.go
index 014f9d69c..0dc760ea8 100644
--- a/services/schedulers.go
+++ b/services/schedulers.go
@@ -123,7 +123,7 @@ func (schS *SchedulerService) Shutdown() (err error) {
func (schS *SchedulerService) IsRunning() bool {
schS.RLock()
defer schS.RUnlock()
- return schS != nil && schS.schS != nil
+ return schS.schS != nil
}
// ServiceName returns the service name
diff --git a/services/sessions.go b/services/sessions.go
index f9f8cc997..ede17c978 100644
--- a/services/sessions.go
+++ b/services/sessions.go
@@ -163,7 +163,7 @@ func (smg *SessionService) Shutdown() (err error) {
func (smg *SessionService) IsRunning() bool {
smg.RLock()
defer smg.RUnlock()
- return smg != nil && smg.sm != nil
+ return smg.sm != nil
}
// ServiceName returns the service name
diff --git a/services/sipagent.go b/services/sipagent.go
index 9c16ffbd7..b1b7a990e 100644
--- a/services/sipagent.go
+++ b/services/sipagent.go
@@ -115,7 +115,7 @@ func (sip *SIPAgent) Shutdown() (err error) {
func (sip *SIPAgent) IsRunning() bool {
sip.RLock()
defer sip.RUnlock()
- return sip != nil && sip.sip != nil
+ return sip.sip != nil
}
// ServiceName returns the service name
diff --git a/services/stats.go b/services/stats.go
index ad6f5c82b..6caf2aad3 100644
--- a/services/stats.go
+++ b/services/stats.go
@@ -126,7 +126,7 @@ func (sts *StatService) Shutdown() (err error) {
func (sts *StatService) IsRunning() bool {
sts.RLock()
defer sts.RUnlock()
- return sts != nil && sts.sts != nil
+ return sts.sts != nil
}
// ServiceName returns the service name
diff --git a/services/thresholds.go b/services/thresholds.go
index cf3fd722a..909ae1d41 100644
--- a/services/thresholds.go
+++ b/services/thresholds.go
@@ -122,7 +122,7 @@ func (thrs *ThresholdService) Shutdown() (err error) {
func (thrs *ThresholdService) IsRunning() bool {
thrs.RLock()
defer thrs.RUnlock()
- return thrs != nil && thrs.thrs != nil
+ return thrs.thrs != nil
}
// ServiceName returns the service name
diff --git a/sessions/sessions.go b/sessions/sessions.go
index 3c685468e..8ba88ca72 100644
--- a/sessions/sessions.go
+++ b/sessions/sessions.go
@@ -2591,10 +2591,10 @@ func (args *V1TerminateSessionArgs) ParseFlags(flags, sep string) {
args.TerminateSession = true
case subsystem == utils.MetaResources:
args.ReleaseResources = true
- case strings.Index(subsystem, utils.MetaThresholds) != -1:
+ case strings.Contains(subsystem, utils.MetaThresholds):
args.ProcessThresholds = true
args.ThresholdIDs = getFlagIDs(subsystem)
- case strings.Index(subsystem, utils.MetaStats) != -1:
+ case strings.Contains(subsystem, utils.MetaStats):
args.ProcessStats = true
args.StatIDs = getFlagIDs(subsystem)
case subsystem == utils.MetaFD:
@@ -2849,13 +2849,13 @@ func (args *V1ProcessMessageArgs) ParseFlags(flags, sep string) {
args.RoutesMaxCost = utils.MetaEventCost
case strings.HasPrefix(subsystem, utils.MetaRoutesMaxCost):
args.RoutesMaxCost = strings.TrimPrefix(subsystem, utils.MetaRoutesMaxCost+utils.InInFieldSep)
- case strings.Index(subsystem, utils.MetaAttributes) != -1:
+ case strings.Contains(subsystem, utils.MetaAttributes):
args.GetAttributes = true
args.AttributeIDs = getFlagIDs(subsystem)
- case strings.Index(subsystem, utils.MetaThresholds) != -1:
+ case strings.Contains(subsystem, utils.MetaThresholds):
args.ProcessThresholds = true
args.ThresholdIDs = getFlagIDs(subsystem)
- case strings.Index(subsystem, utils.MetaStats) != -1:
+ case strings.Contains(subsystem, utils.MetaStats):
args.ProcessStats = true
args.StatIDs = getFlagIDs(subsystem)
case subsystem == utils.MetaFD:
diff --git a/utils/coreutils_test.go b/utils/coreutils_test.go
index 852e01fd3..a59d4c5b4 100644
--- a/utils/coreutils_test.go
+++ b/utils/coreutils_test.go
@@ -28,7 +28,6 @@ import (
"golang.org/x/crypto/bcrypt"
- "github.com/cgrates/birpc"
"github.com/cgrates/rpcclient"
)
@@ -1779,32 +1778,6 @@ func TestMonthlyEstimated(t *testing.T) {
}
}
-type server struct{}
-
-type client struct{}
-
-func (c client) Call(serviceMethod string, args any, reply any) (err error) {
- err = ErrExists
- return
-}
-
-func (srv *server) BiRPCv1ValidMethod(cl birpc.ClientConnector, args any, req any) error {
- return nil
-}
-
-func (srv *server) BiRPCv1MultipleParams(cl birpc.ClientConnector, args any, req any) (int, error) {
- return 1, nil
-}
-
-func (srv *server) BiRPCv1NoErrorReturn(cl birpc.ClientConnector, args any, req any) int {
- return 1
-}
-
-func (srv *server) BiRPCv1FinalError(cl birpc.ClientConnector, args any, req any) (err error) {
- err = ErrExists
- return
-}
-
func TestCoreUtilsGenerateDBItemOpts(t *testing.T) {
apiKey := "testKey1"
routeID := "testKey2"
diff --git a/utils/dynamicweight.go b/utils/dynamicweight.go
index 6ab35e779..53c79bf48 100644
--- a/utils/dynamicweight.go
+++ b/utils/dynamicweight.go
@@ -78,9 +78,7 @@ func (dW *DynamicWeight) Clone() (dinWeight *DynamicWeight) {
}
if dW.FilterIDs != nil {
dinWeight.FilterIDs = make([]string, len(dW.FilterIDs))
- for i, value := range dW.FilterIDs {
- dinWeight.FilterIDs[i] = value
- }
+ copy(dinWeight.FilterIDs, dW.FilterIDs)
}
return dinWeight
}
diff --git a/utils/map.go b/utils/map.go
index d476a987f..f21ca9c5c 100644
--- a/utils/map.go
+++ b/utils/map.go
@@ -86,9 +86,7 @@ func (sm StringMap) Slice() []string {
}
func (sm StringMap) IsEmpty() bool {
- return sm == nil ||
- len(sm) == 0 ||
- sm[MetaAny]
+ return len(sm) == 0 || sm[MetaAny]
}
func StringMapFromSlice(s []string) StringMap {
@@ -273,7 +271,7 @@ func (fWp FlagsWithParams) GetBool(key string) (b bool) {
if v, b = fWp[key]; !b {
return // not present means false
}
- if v == nil || len(v) == 0 {
+ if len(v) == 0 {
return true // empty map
}
return v.Has(TrueStr) || !v.Has(FalseStr)