mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Removed warnings from go staticcheck
This commit is contained in:
committed by
Dan Christian Bogos
parent
529430bd4d
commit
c2dacc42c1
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user