Skip to content

Commit 5b3280a

Browse files
AmanGIT07claude
andauthored
chore: apply go fix modernizers (#1825)
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
1 parent 990e142 commit 5b3280a

95 files changed

Lines changed: 516 additions & 560 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎billing/checkout/service.go‎

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
285285
quantity = userCount
286286
}
287287
itemParams := &stripe.CheckoutSessionLineItemParams{
288-
Price: stripe.String(productPrice.ProviderID),
289-
Quantity: stripe.Int64(quantity),
288+
Price: new(productPrice.ProviderID),
289+
Quantity: new(quantity),
290290
}
291291
subsItems = append(subsItems, itemParams)
292292
}
@@ -302,7 +302,7 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
302302
return Checkout{}, err
303303
}
304304
if plan.TrialDays > 0 && !ch.SkipTrial && !userHasTrialedBefore {
305-
trialDays = stripe.Int64(plan.TrialDays)
305+
trialDays = new(plan.TrialDays)
306306
}
307307

308308
// create subscription checkout link
@@ -311,10 +311,10 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
311311
Context: ctx,
312312
},
313313
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{
314-
Enabled: stripe.Bool(s.stripeAutoTax),
314+
Enabled: new(s.stripeAutoTax),
315315
},
316-
Currency: stripe.String(billingCustomer.Currency),
317-
Customer: stripe.String(billingCustomer.ProviderID),
316+
Currency: new(billingCustomer.Currency),
317+
Customer: new(billingCustomer.ProviderID),
318318
LineItems: subsItems,
319319
Metadata: map[string]string{
320320
"org_id": billingCustomer.OrgID,
@@ -324,11 +324,11 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
324324
"managed_by": "frontier",
325325
},
326326
CustomerUpdate: &stripe.CheckoutSessionCustomerUpdateParams{
327-
Address: stripe.String(addressCollectionParam),
327+
Address: new(addressCollectionParam),
328328
},
329329
Mode: stripe.String(string(stripe.CheckoutSessionModeSubscription)),
330330
SubscriptionData: &stripe.CheckoutSessionSubscriptionDataParams{
331-
Description: stripe.String(fmt.Sprintf("Checkout for %s", plan.Name)),
331+
Description: new(fmt.Sprintf("Checkout for %s", plan.Name)),
332332
Metadata: map[string]string{
333333
"org_id": billingCustomer.OrgID,
334334
CheckoutIDMetadataKey: checkoutID,
@@ -342,10 +342,10 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
342342
},
343343
},
344344
},
345-
AllowPromotionCodes: stripe.Bool(true),
346-
CancelURL: stripe.String(ch.CancelUrl),
347-
SuccessURL: stripe.String(ch.SuccessUrl),
348-
ExpiresAt: stripe.Int64(time.Now().Add(SessionValidity).Unix()),
345+
AllowPromotionCodes: new(true),
346+
CancelURL: new(ch.CancelUrl),
347+
SuccessURL: new(ch.SuccessUrl),
348+
ExpiresAt: new(time.Now().Add(SessionValidity).Unix()),
349349
PaymentMethodCollection: stripe.String(string(stripe.PaymentLinkPaymentMethodCollectionIfRequired)),
350350
})
351351
if err != nil {
@@ -408,17 +408,17 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
408408
continue
409409
}
410410
itemParams := &stripe.CheckoutSessionLineItemParams{
411-
Price: stripe.String(productPrice.ProviderID),
411+
Price: new(productPrice.ProviderID),
412412
AdjustableQuantity: &stripe.CheckoutSessionLineItemAdjustableQuantityParams{
413-
Enabled: stripe.Bool(adjustableQuantity),
413+
Enabled: new(adjustableQuantity),
414414
},
415415
}
416416
if adjustableQuantity {
417-
itemParams.AdjustableQuantity.Minimum = stripe.Int64(minQ)
418-
itemParams.AdjustableQuantity.Maximum = stripe.Int64(maxQ)
417+
itemParams.AdjustableQuantity.Minimum = new(minQ)
418+
itemParams.AdjustableQuantity.Maximum = new(maxQ)
419419
}
420420
if productPrice.UsageType == product.PriceUsageTypeLicensed {
421-
itemParams.Quantity = stripe.Int64(defaultQ)
421+
itemParams.Quantity = new(defaultQ)
422422
}
423423

424424
if productPrice.Currency == s.defaultCurrency {
@@ -435,7 +435,7 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
435435
var paymentMethodTypes []*string
436436
for _, paymentMethodConfig := range s.paymentMethodConfig {
437437
if paymentMethodConfig.IsAllowedForAmount(amountSubtotal) {
438-
paymentMethodTypes = append(paymentMethodTypes, stripe.String(paymentMethodConfig.Type))
438+
paymentMethodTypes = append(paymentMethodTypes, new(paymentMethodConfig.Type))
439439
}
440440
}
441441

@@ -445,12 +445,12 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
445445
Context: ctx,
446446
},
447447
AutomaticTax: &stripe.CheckoutSessionAutomaticTaxParams{
448-
Enabled: stripe.Bool(s.stripeAutoTax),
448+
Enabled: new(s.stripeAutoTax),
449449
},
450-
Currency: stripe.String(s.defaultCurrency),
451-
Customer: stripe.String(billingCustomer.ProviderID),
450+
Currency: new(s.defaultCurrency),
451+
Customer: new(billingCustomer.ProviderID),
452452
InvoiceCreation: &stripe.CheckoutSessionInvoiceCreationParams{
453-
Enabled: stripe.Bool(true),
453+
Enabled: new(true),
454454
},
455455
LineItems: subsItems,
456456
Mode: stripe.String(string(stripe.CheckoutSessionModePayment)),
@@ -463,12 +463,12 @@ func (s *Service) Create(ctx context.Context, ch Checkout) (Checkout, error) {
463463
"managed_by": "frontier",
464464
},
465465
CustomerUpdate: &stripe.CheckoutSessionCustomerUpdateParams{
466-
Address: stripe.String(addressCollectionParam),
466+
Address: new(addressCollectionParam),
467467
},
468-
AllowPromotionCodes: stripe.Bool(true),
469-
CancelURL: stripe.String(ch.CancelUrl),
470-
SuccessURL: stripe.String(ch.SuccessUrl),
471-
ExpiresAt: stripe.Int64(time.Now().Add(SessionValidity).Unix()),
468+
AllowPromotionCodes: new(true),
469+
CancelURL: new(ch.CancelUrl),
470+
SuccessURL: new(ch.SuccessUrl),
471+
ExpiresAt: new(time.Now().Add(SessionValidity).Unix()),
472472
PaymentMethodTypes: paymentMethodTypes,
473473
PaymentMethodOptions: &stripe.CheckoutSessionPaymentMethodOptionsParams{
474474
CustomerBalance: &stripe.CheckoutSessionPaymentMethodOptionsCustomerBalanceParams{
@@ -554,7 +554,7 @@ func (s *Service) SyncWithProvider(ctx context.Context, customerID string) error
554554
Context: ctx,
555555
},
556556
Expand: []*string{
557-
stripe.String("line_items.data.price.product"),
557+
new("line_items.data.price.product"),
558558
},
559559
})
560560
if err != nil {
@@ -782,12 +782,12 @@ func (s *Service) CreateSessionForPaymentMethod(ctx context.Context, ch Checkout
782782
Params: stripe.Params{
783783
Context: ctx,
784784
},
785-
Customer: stripe.String(billingCustomer.ProviderID),
786-
Currency: stripe.String(billingCustomer.Currency),
785+
Customer: new(billingCustomer.ProviderID),
786+
Currency: new(billingCustomer.Currency),
787787
Mode: stripe.String(string(stripe.CheckoutSessionModeSetup)),
788-
CancelURL: stripe.String(ch.CancelUrl),
789-
SuccessURL: stripe.String(ch.SuccessUrl),
790-
ExpiresAt: stripe.Int64(time.Now().Add(SessionValidity).Unix()),
788+
CancelURL: new(ch.CancelUrl),
789+
SuccessURL: new(ch.SuccessUrl),
790+
ExpiresAt: new(time.Now().Add(SessionValidity).Unix()),
791791
Metadata: map[string]string{
792792
"org_id": billingCustomer.OrgID,
793793
"checkout_id": checkoutID,
@@ -827,11 +827,11 @@ func (s *Service) CreateSessionForCustomerPortal(ctx context.Context, ch Checkou
827827
Params: stripe.Params{
828828
Context: ctx,
829829
},
830-
Customer: stripe.String(billingCustomer.ProviderID),
830+
Customer: new(billingCustomer.ProviderID),
831831
}
832832

833833
if ch.CancelUrl != "" {
834-
sessionParams.ReturnURL = stripe.String(ch.CancelUrl)
834+
sessionParams.ReturnURL = new(ch.CancelUrl)
835835
}
836836

837837
session, err := s.stripeClient.BillingPortalSessions.New(sessionParams)
@@ -870,7 +870,7 @@ func (s *Service) Apply(ctx context.Context, ch Checkout) (*subscription.Subscri
870870
}
871871

872872
autoTaxParams := &stripe.SubscriptionAutomaticTaxParams{
873-
Enabled: stripe.Bool(s.stripeAutoTax),
873+
Enabled: new(s.stripeAutoTax),
874874
}
875875

876876
// checkout could be for a plan or a product
@@ -929,8 +929,8 @@ func (s *Service) Apply(ctx context.Context, ch Checkout) (*subscription.Subscri
929929
}
930930

931931
itemParams := &stripe.SubscriptionItemsParams{
932-
Price: stripe.String(productPrice.ProviderID),
933-
Quantity: stripe.Int64(quantity),
932+
Price: new(productPrice.ProviderID),
933+
Quantity: new(quantity),
934934
Metadata: map[string]string{
935935
"org_id": billingCustomer.OrgID,
936936
"product_id": planProduct.ID,
@@ -946,28 +946,28 @@ func (s *Service) Apply(ctx context.Context, ch Checkout) (*subscription.Subscri
946946

947947
var trialDays *int64 = nil
948948
if plan.TrialDays > 0 && !ch.SkipTrial {
949-
trialDays = stripe.Int64(plan.TrialDays)
949+
trialDays = new(plan.TrialDays)
950950
}
951951

952952
if totalExpectedPrice == 0 {
953953
// if total price is 0, disable auto tax. This ensures that when the subscription is created without
954954
// user billing details while onboarding, creating 0 amount invoice doesn't fail
955955
// This will be toggled back on when the user changes it's plan to a paid one
956-
autoTaxParams.Enabled = stripe.Bool(false)
956+
autoTaxParams.Enabled = new(false)
957957
}
958958

959959
var couponID *string
960960
if ch.ProviderCouponID != "" {
961-
couponID = stripe.String(ch.ProviderCouponID)
961+
couponID = new(ch.ProviderCouponID)
962962
}
963963
// create subscription directly
964964
stripeSubscription, err := s.stripeClient.Subscriptions.New(&stripe.SubscriptionParams{
965965
Params: stripe.Params{
966966
Context: ctx,
967967
},
968968
AutomaticTax: autoTaxParams,
969-
Customer: stripe.String(billingCustomer.ProviderID),
970-
Currency: stripe.String(billingCustomer.Currency),
969+
Customer: new(billingCustomer.ProviderID),
970+
Currency: new(billingCustomer.Currency),
971971
Items: subsItems,
972972
Metadata: map[string]string{
973973
"org_id": billingCustomer.OrgID,

‎billing/checkout/service_concurrent_test.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ func TestService_InitClose_Concurrent(t *testing.T) {
1818
}
1919

2020
var wg sync.WaitGroup
21-
for i := 0; i < 2; i++ {
22-
wg.Add(1)
23-
go func() {
24-
defer wg.Done()
21+
for range 2 {
22+
wg.Go(func() {
2523
if err := s.Init(context.Background()); err != nil {
2624
t.Errorf("Init: %v", err)
2725
}
28-
}()
26+
})
2927
}
3028
wg.Wait()
3129

‎billing/credit/service.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ func (s Service) createAuditRecord(ctx context.Context, customerID string, event
192192
Target: &auditrecord.Target{
193193
ID: txID,
194194
Type: pkgAuditRecord.BillingTransactionType,
195-
Metadata: map[string]interface{}{
195+
Metadata: map[string]any{
196196
"amount": txEntry.Amount,
197197
"source": txEntry.Source,
198198
"description": txEntry.Description,

‎billing/customer/service.go‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ func (s *Service) RegisterToProvider(ctx context.Context, customer Customer) (*s
106106
var customerTaxes []*stripe.CustomerTaxIDDataParams = nil
107107
for _, tax := range customer.TaxData {
108108
customerTaxes = append(customerTaxes, &stripe.CustomerTaxIDDataParams{
109-
Type: stripe.String(tax.Type),
110-
Value: stripe.String(tax.ID),
109+
Type: new(tax.Type),
110+
Value: new(tax.ID),
111111
})
112112
}
113113
// create a new customer in stripe
@@ -318,12 +318,12 @@ func (s *Service) ListPaymentMethods(ctx context.Context, id string) ([]PaymentM
318318
}
319319

320320
stripePaymentMethodItr := s.stripeClient.PaymentMethods.List(&stripe.PaymentMethodListParams{
321-
Customer: stripe.String(customer.ProviderID),
321+
Customer: new(customer.ProviderID),
322322
ListParams: stripe.ListParams{
323323
Context: ctx,
324324
},
325325
Expand: []*string{
326-
stripe.String("data.customer"),
326+
new("data.customer"),
327327
},
328328
})
329329

‎billing/customer/service_concurrent_test.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@ func TestService_InitClose_Concurrent(t *testing.T) {
1818
}
1919

2020
var wg sync.WaitGroup
21-
for i := 0; i < 2; i++ {
22-
wg.Add(1)
23-
go func() {
24-
defer wg.Done()
21+
for range 2 {
22+
wg.Go(func() {
2523
if err := s.Init(context.Background()); err != nil {
2624
t.Errorf("Init: %v", err)
2725
}
28-
}()
26+
})
2927
}
3028
wg.Wait()
3129

‎billing/customer/service_test.go‎

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -138,16 +138,16 @@ func TestService_Create(t *testing.T) {
138138
Context: ctx,
139139
},
140140
Address: &stripe.AddressParams{
141-
City: stripe.String(""),
142-
Country: stripe.String(""),
143-
Line1: stripe.String(""),
144-
Line2: stripe.String(""),
145-
PostalCode: stripe.String(""),
146-
State: stripe.String(""),
141+
City: new(""),
142+
Country: new(""),
143+
Line1: new(""),
144+
Line2: new(""),
145+
PostalCode: new(""),
146+
State: new(""),
147147
},
148-
Email: stripe.String(""),
149-
Name: stripe.String("customer1"),
150-
Phone: stripe.String(""),
148+
Email: new(""),
149+
Name: new("customer1"),
150+
Phone: new(""),
151151
TaxIDData: nil,
152152
Metadata: map[string]string{
153153
"managed_by": "frontier",
@@ -232,16 +232,16 @@ func TestService_Update(t *testing.T) {
232232
Context: ctx,
233233
},
234234
Address: &stripe.AddressParams{
235-
City: stripe.String(""),
236-
Country: stripe.String(""),
237-
Line1: stripe.String(""),
238-
Line2: stripe.String(""),
239-
PostalCode: stripe.String(""),
240-
State: stripe.String(""),
235+
City: new(""),
236+
Country: new(""),
237+
Line1: new(""),
238+
Line2: new(""),
239+
PostalCode: new(""),
240+
State: new(""),
241241
},
242-
Email: stripe.String(""),
243-
Name: stripe.String("customer1"),
244-
Phone: stripe.String(""),
242+
Email: new(""),
243+
Name: new("customer1"),
244+
Phone: new(""),
245245
TaxIDData: nil,
246246
Metadata: map[string]string{
247247
"managed_by": "frontier",
@@ -314,16 +314,16 @@ func TestService_Update(t *testing.T) {
314314
Context: ctx,
315315
},
316316
Address: &stripe.AddressParams{
317-
City: stripe.String(""),
318-
Country: stripe.String(""),
319-
Line1: stripe.String(""),
320-
Line2: stripe.String(""),
321-
PostalCode: stripe.String(""),
322-
State: stripe.String(""),
317+
City: new(""),
318+
Country: new(""),
319+
Line1: new(""),
320+
Line2: new(""),
321+
PostalCode: new(""),
322+
State: new(""),
323323
},
324-
Email: stripe.String(""),
325-
Name: stripe.String("customer1"),
326-
Phone: stripe.String(""),
324+
Email: new(""),
325+
Name: new("customer1"),
326+
Phone: new(""),
327327
TaxIDData: nil,
328328
Metadata: map[string]string{
329329
"managed_by": "frontier",

0 commit comments

Comments
 (0)