commit 071ed2ba8ae385f63e9e12a86eef3ae878e7f939
parent 1ec82652c7bf326f8c8438437ef7a55179b14a11
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Mon, 16 Nov 2026 11:37:14 +0100
update vendored dependencies
Diffstat:
15 files changed, 450 insertions(+), 210 deletions(-)
diff --git a/go.mod b/go.mod
@@ -1,13 +1,13 @@
module taler.net/taler-mailbox
-go 1.25.0
+go 1.26.0
require (
github.com/gorilla/mux v1.8.1
github.com/lib/pq v1.12.3
- github.com/schanzen/taler-go v1.5.2
- gopkg.in/ini.v1 v1.67.1
+ github.com/schanzen/taler-go v1.6.0
+ gopkg.in/ini.v1 v1.68.0
rsc.io/getopt v0.0.0-20170811000552-20be20937449
)
-require golang.org/x/text v0.36.0 // indirect
+require golang.org/x/text v0.44.0 // indirect
diff --git a/go.sum b/go.sum
@@ -9,6 +9,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/schanzen/taler-go v1.5.2 h1:Db7jRl+CaJ3ylvxFS/umFOyPxg/qhHj2qKEOzXfNbIM=
github.com/schanzen/taler-go v1.5.2/go.mod h1:Q6xJcRUjnB15MbceZXF7FPBdqBid2a232VpVFyNY/So=
+github.com/schanzen/taler-go v1.6.0 h1:wYLVbQiIIsBr1LeOmJlglHZeMzxahCDsNPZH7thErEI=
+github.com/schanzen/taler-go v1.6.0/go.mod h1:Q6xJcRUjnB15MbceZXF7FPBdqBid2a232VpVFyNY/So=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@@ -20,9 +22,13 @@ github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
golang.org/x/text v0.36.0 h1:JfKh3XmcRPqZPKevfXVpI1wXPTqbkE5f7JA92a55Yxg=
golang.org/x/text v0.36.0/go.mod h1:NIdBknypM8iqVmPiuco0Dh6P5Jcdk8lJL0CUebqK164=
+golang.org/x/text v0.44.0 h1:YItdp/mQNGnsmrgpcdA5yQ3bnRxCfo/Tj/iByGW9GGo=
+golang.org/x/text v0.44.0/go.mod h1:S4FR1waQ9LbjQTls97SyRjDaUUVkaM+cXwwuG/G+MwY=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/ini.v1 v1.67.1 h1:tVBILHy0R6e4wkYOn3XmiITt/hEVH4TFMYvAX2Ytz6k=
gopkg.in/ini.v1 v1.67.1/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss=
+gopkg.in/ini.v1 v1.68.0 h1:Ml6Jlmf35dsiLcxJaRSjck7dxkxCOHd9T/E1f6jV9EE=
+gopkg.in/ini.v1 v1.68.0/go.mod h1:x/cyOwCgZqOkJoDIJ3c1KNHMo10+nLGAhh+kn3Zizss=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
diff --git a/vendor/github.com/schanzen/taler-go/pkg/merchant/merchant.go b/vendor/github.com/schanzen/taler-go/pkg/merchant/merchant.go
@@ -2,11 +2,15 @@ package merchant
import (
"bytes"
+ "context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
+ "net/url"
+ "strings"
+ "time"
"github.com/schanzen/taler-go/pkg/util"
)
@@ -25,6 +29,28 @@ type MerchantConfig struct {
Version string `json:"version"`
}
+// Timestamp is an absolute time as the merchant API encodes it:
+// {"t_s": seconds since the epoch}.
+type Timestamp struct {
+ Seconds int64 `json:"t_s"`
+}
+
+// TimestampOf converts t to a Timestamp, truncating to whole seconds.
+func TimestampOf(t time.Time) *Timestamp {
+ return &Timestamp{Seconds: t.Unix()}
+}
+
+// RelativeTime is a duration as the merchant API encodes it:
+// {"d_us": microseconds}.
+type RelativeTime struct {
+ Microseconds int64 `json:"d_us"`
+}
+
+// RelativeTimeOf converts d to a RelativeTime.
+func RelativeTimeOf(d time.Duration) *RelativeTime {
+ return &RelativeTime{Microseconds: d.Microseconds()}
+}
+
type PostOrderRequest struct {
// The order must at least contain the minimal
// order detail, but can override all.
@@ -33,7 +59,7 @@ type PostOrderRequest struct {
// If set, the backend will then set the refund deadline to the current
// time plus the specified delay. If it's not set, refunds will not be
// possible.
- RefundDelay int64 `json:"refund_delay,omitempty"`
+ RefundDelay *RelativeTime `json:"refund_delay,omitempty"`
// Specifies the payment target preferred by the client. Can be used
// to select among the various (active) wire methods supported by the instance.
@@ -60,7 +86,8 @@ type PostOrderRequest struct {
// False can make sense if the ORDER_ID is sufficiently
// high entropy to prevent adversarial claims (like it is
// if the backend auto-generates one). Default is 'true'.
- CreateToken bool `json:"create_token,omitempty"`
+ // A pointer, so that false is sent; omitempty would drop a plain false.
+ CreateToken *bool `json:"create_token,omitempty"`
}
type CommonOrder struct {
@@ -116,23 +143,23 @@ type CommonOrder struct {
// Time when this contract was generated. If null, defaults to current
// time of merchant backend.
- Timestamp *uint64 `json:"timestamp,omitempty"`
+ Timestamp *Timestamp `json:"timestamp,omitempty"`
// After this deadline has passed, no refunds will be accepted.
// Overrides deadline calculated from refund_delay in
// PostOrderRequest.
- RefundDeadline *uint64 `json:"refund_deadline,omitempty"`
+ RefundDeadline *Timestamp `json:"refund_deadline,omitempty"`
// After this deadline, the merchant won't accept payments for the contract.
// Overrides deadline calculated from default pay delay configured in
// merchant backend.
- PayDeadline *uint64 `json:"pay_deadline,omitempty"`
+ PayDeadline *Timestamp `json:"pay_deadline,omitempty"`
// Transfer deadline for the exchange. Must be in the deposit permissions
// of coins used to pay for this order.
// Overrides deadline calculated from default wire transfer delay
// configured in merchant backend. Must be after refund deadline.
- WireTransferDeadline *uint64 `json:"wire_transfer_deadline,omitempty"`
+ WireTransferDeadline *Timestamp `json:"wire_transfer_deadline,omitempty"`
// Base URL of the (public!) merchant backend API.
// Must be an absolute URL that ends with a slash.
@@ -145,18 +172,18 @@ type CommonOrder struct {
// Time indicating when the order should be delivered.
// May be overwritten by individual products.
// Must be in the future.
- DeliveryDate *uint64 `json:"delivery_deadline,omitempty"`
+ DeliveryDate *Timestamp `json:"delivery_date,omitempty"`
// See documentation of auto_refund in ContractTerms.
// Specifies for how long the wallet should try to get an
// automatic refund for the purchase.
- AutoRefund *uint64 `json:"auto_refund,omitempty"`
+ AutoRefund *RelativeTime `json:"auto_refund,omitempty"`
// Extra data that is only interpreted by the merchant frontend.
// Useful when the merchant needs to store extra information on a
// contract without storing it separately in their database.
// Must really be an Object (not a string, integer, float or array).
- Extra string
+ Extra json.RawMessage `json:"extra,omitempty"`
}
// NOTE: Part of the above but optional
@@ -199,8 +226,17 @@ type Merchant struct {
// The access token to use for the private API
AccessToken string
+
+ // HTTPClient sends the requests. When it is nil, a client whose
+ // requests time out after DefaultTimeout is used.
+ HTTPClient *http.Client
}
+// DefaultTimeout limits each request when Merchant.HTTPClient is nil.
+const DefaultTimeout = 30 * time.Second
+
+var defaultClient = &http.Client{Timeout: DefaultTimeout}
+
func NewMerchant(merchBaseUrlPrivate string, merchAccessToken string) Merchant {
return Merchant{
BaseUrlPrivate: merchBaseUrlPrivate,
@@ -208,6 +244,24 @@ func NewMerchant(merchBaseUrlPrivate string, merchAccessToken string) Merchant {
}
}
+func (m *Merchant) client() *http.Client {
+ if m.HTTPClient != nil {
+ return m.HTTPClient
+ }
+ return defaultClient
+}
+
+// authorization is the Authorization header value for the private API.
+// AccessToken may be given with or without its "secret-token:" prefix.
+func (m *Merchant) authorization() string {
+ if strings.HasPrefix(m.AccessToken, secretTokenPrefix) {
+ return "Bearer " + m.AccessToken
+ }
+ return "Bearer " + secretTokenPrefix + m.AccessToken
+}
+
+const secretTokenPrefix = "secret-token:"
+
type PaymentStatus string
const (
@@ -218,14 +272,23 @@ const (
)
func (m *Merchant) IsOrderPaid(orderId string) (int, PaymentStatus, string, error) {
+ return m.IsOrderPaidContext(context.Background(), orderId)
+}
+
+// IsOrderPaidContext is IsOrderPaid with a context that can cancel the
+// request or limit its duration.
+func (m *Merchant) IsOrderPaidContext(ctx context.Context, orderId string) (int, PaymentStatus, string, error) {
var orderPaidResponse CheckPaymentStatusResponse
var paytoResponse CheckPaymentPaytoResponse
- client := &http.Client{}
- req, _ := http.NewRequest("GET", m.BaseUrlPrivate+"/private/orders/"+orderId, nil)
- req.Header.Set("Authorization", "Bearer secret-token:"+m.AccessToken)
- resp, err := client.Do(req)
+ req, err := http.NewRequestWithContext(ctx, "GET", m.BaseUrlPrivate+"/private/orders/"+url.PathEscape(orderId), nil)
+ if err != nil {
+ return 0, OrderStatusUnknown, "", err
+ }
+ req.Header.Set("Authorization", m.authorization())
+ resp, err := m.client().Do(req)
if nil != err {
- return resp.StatusCode, OrderStatusUnknown, "", err
+ // resp is nil when the request failed; there is no status code.
+ return 0, OrderStatusUnknown, "", err
}
defer resp.Body.Close()
if http.StatusOK != resp.StatusCode {
@@ -248,10 +311,18 @@ func (m *Merchant) IsOrderPaid(orderId string) (int, PaymentStatus, string, erro
}
func (m *Merchant) GetConfig() (*MerchantConfig, error) {
+ return m.GetConfigContext(context.Background())
+}
+
+// GetConfigContext is GetConfig with a context that can cancel the request
+// or limit its duration.
+func (m *Merchant) GetConfigContext(ctx context.Context) (*MerchantConfig, error) {
var configResponse MerchantConfig
- client := &http.Client{}
- req, _ := http.NewRequest("GET", m.BaseUrlPrivate+"/config", nil)
- resp, err := client.Do(req)
+ req, err := http.NewRequestWithContext(ctx, "GET", m.BaseUrlPrivate+"/config", nil)
+ if err != nil {
+ return nil, err
+ }
+ resp, err := m.client().Do(req)
if nil != err {
return nil, err
}
@@ -271,23 +342,44 @@ func (m *Merchant) GetConfig() (*MerchantConfig, error) {
return &configResponse, nil
}
+// ErrOrderExists is returned by CreateOrder when the backend already has an
+// order with the requested OrderId (HTTP 409 Conflict). A caller that
+// chooses its own order IDs can treat it as success when it retries a
+// creation whose answer it never received.
+var ErrOrderExists = errors.New("merchant: an order with this ID already exists")
+
func (m *Merchant) CreateOrder(order CommonOrder) (string, error) {
+ return m.CreateOrderContext(context.Background(), order)
+}
+
+// CreateOrderContext is CreateOrder with a context that can cancel the
+// request or limit its duration.
+func (m *Merchant) CreateOrderContext(ctx context.Context, order CommonOrder) (string, error) {
var newOrder PostOrderRequest
- var orderResponse PostOrderResponse
newOrder.Order = order
+ return m.postOrder(ctx, newOrder)
+}
+
+func (m *Merchant) postOrder(ctx context.Context, newOrder PostOrderRequest) (string, error) {
+ var orderResponse PostOrderResponse
reqString, err := json.Marshal(newOrder)
if nil != err {
return "", err
}
- client := &http.Client{}
- req, _ := http.NewRequest(http.MethodPost, m.BaseUrlPrivate+"/private/orders", bytes.NewReader(reqString))
- req.Header.Set("Authorization", "Bearer secret-token:"+m.AccessToken)
- resp, err := client.Do(req)
+ req, err := http.NewRequestWithContext(ctx, http.MethodPost, m.BaseUrlPrivate+"/private/orders", bytes.NewReader(reqString))
+ if err != nil {
+ return "", err
+ }
+ req.Header.Set("Authorization", m.authorization())
+ resp, err := m.client().Do(req)
if nil != err {
return "", err
}
defer resp.Body.Close()
+ if http.StatusConflict == resp.StatusCode {
+ return newOrder.Order.OrderId, ErrOrderExists
+ }
if http.StatusOK != resp.StatusCode {
message := fmt.Sprintf("Expected response code %d. Got %d. With request %s", http.StatusOK, resp.StatusCode, reqString)
return "", errors.New(message)
@@ -299,29 +391,10 @@ func (m *Merchant) CreateOrder(order CommonOrder) (string, error) {
func (m *Merchant) AddNewOrder(cost util.Amount, summary string, fulfillment_url string) (string, error) {
var newOrder PostOrderRequest
var orderDetail CommonOrder
- var orderResponse PostOrderResponse
orderDetail.Amount = cost.String()
// FIXME get from cfg
orderDetail.Summary = summary
orderDetail.FulfillmentUrl = fulfillment_url
newOrder.Order = orderDetail
- reqString, err := json.Marshal(newOrder)
- if nil != err {
- return "", err
- }
- client := &http.Client{}
- req, _ := http.NewRequest(http.MethodPost, m.BaseUrlPrivate+"/private/orders", bytes.NewReader(reqString))
- req.Header.Set("Authorization", "Bearer secret-token:"+m.AccessToken)
- resp, err := client.Do(req)
-
- if nil != err {
- return "", err
- }
- defer resp.Body.Close()
- if http.StatusOK != resp.StatusCode {
- message := fmt.Sprintf("Expected response code %d. Got %d. With request %s", http.StatusOK, resp.StatusCode, reqString)
- return "", errors.New(message)
- }
- err = json.NewDecoder(resp.Body).Decode(&orderResponse)
- return orderResponse.OrderId, err
+ return m.postOrder(context.Background(), newOrder)
}
diff --git a/vendor/golang.org/x/text/language/parse.go b/vendor/golang.org/x/text/language/parse.go
@@ -166,7 +166,9 @@ func ParseAcceptLanguage(s string) (tag []Tag, q []float32, err error) {
}
}()
- if strings.Count(s, "-") > 1000 {
+ // The BCP 47 scanner aliases '_' to '-' in scanner.init
+ // (internal/language/parse.go); the guard must count both.
+ if strings.Count(s, "-")+strings.Count(s, "_") > 1000 {
return nil, nil, errTagListTooLarge
}
diff --git a/vendor/gopkg.in/ini.v1/.golangci.yml b/vendor/gopkg.in/ini.v1/.golangci.yml
@@ -6,11 +6,6 @@ linters:
- unconvert
- unparam
settings:
- govet:
- disable:
- # printf: non-constant format string in call to fmt.Errorf (govet)
- # showing up since golangci-lint version 1.60.1
- - printf
nakedret:
max-func-lines: 0 # Disallow any unnamed return statement
exclusions:
diff --git a/vendor/gopkg.in/ini.v1/README.md b/vendor/gopkg.in/ini.v1/README.md
@@ -1,6 +1,5 @@
# INI
-[](https://github.com/go-ini/ini/actions?query=branch%3Amain)
[](https://pkg.go.dev/github.com/go-ini/ini?tab=doc)

@@ -37,8 +36,6 @@ $ go get gopkg.in/ini.v1@latest
## Getting Help
- [Getting Started](https://ini.unknwon.io/docs/intro/getting_started)
-- [API Documentation](https://gowalker.org/gopkg.in/ini.v1)
-- 中国大陆镜像:https://ini.unknwon.cn
## License
diff --git a/vendor/gopkg.in/ini.v1/data_source.go b/vendor/gopkg.in/ini.v1/data_source.go
@@ -18,7 +18,6 @@ import (
"bytes"
"fmt"
"io"
- "io/ioutil"
"os"
)
@@ -48,7 +47,7 @@ type sourceData struct {
}
func (s *sourceData) ReadCloser() (io.ReadCloser, error) {
- return ioutil.NopCloser(bytes.NewReader(s.data)), nil
+ return io.NopCloser(bytes.NewReader(s.data)), nil
}
// sourceReadCloser represents an input stream with Close method.
@@ -69,7 +68,7 @@ func parseDataSource(source interface{}) (dataSource, error) {
case io.ReadCloser:
return &sourceReadCloser{s}, nil
case io.Reader:
- return &sourceReadCloser{ioutil.NopCloser(s)}, nil
+ return &sourceReadCloser{io.NopCloser(s)}, nil
default:
return nil, fmt.Errorf("error parsing data source: unknown type %q", s)
}
diff --git a/vendor/gopkg.in/ini.v1/file.go b/vendor/gopkg.in/ini.v1/file.go
@@ -19,7 +19,6 @@ import (
"errors"
"fmt"
"io"
- "io/ioutil"
"os"
"strings"
"sync"
@@ -94,7 +93,7 @@ func (f *File) NewSection(name string) (*Section, error) {
defer f.lock.Unlock()
}
- if !f.options.AllowNonUniqueSections && inSlice(name, f.sectionList) {
+ if !f.options.AllowNonUniqueSections && f.sections[name] != nil {
return f.sections[name][0], nil
}
@@ -333,6 +332,32 @@ func (f *File) Append(source interface{}, others ...interface{}) error {
return f.Reload()
}
+func writeCommentLines(buf *bytes.Buffer, comment, indent string) error {
+ if len(comment) == 0 {
+ return nil
+ }
+ lines := strings.Split(comment, LineBreak)
+ for i := range lines {
+ if len(lines[i]) == 0 {
+ continue
+ }
+ if len(indent) > 0 {
+ if _, err := buf.WriteString(indent); err != nil {
+ return err
+ }
+ }
+ if lines[i][0] != '#' && lines[i][0] != ';' {
+ lines[i] = "; " + strings.TrimSpace(lines[i])
+ } else {
+ lines[i] = lines[i][:1] + " " + strings.TrimSpace(lines[i][1:])
+ }
+ if _, err := buf.WriteString(lines[i] + LineBreak); err != nil {
+ return err
+ }
+ }
+ return nil
+}
+
func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
equalSign := DefaultFormatLeft + f.options.KeyValueDelimiterOnWrite + DefaultFormatRight
@@ -367,7 +392,7 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
}
} else {
// Write nothing if default section is empty
- if len(sec.keyList) == 0 {
+ if len(sec.keyList) == 0 && len(sec.TrailingComment) == 0 {
continue
}
}
@@ -377,6 +402,9 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
if _, err := buf.WriteString(sec.rawBody); err != nil {
return nil, err
}
+ if err := writeCommentLines(buf, sec.TrailingComment, ""); err != nil {
+ return nil, err
+ }
if PrettySection && !isLastSection {
// Put a line between sections
@@ -431,10 +459,6 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
}
}
- if len(indent) > 0 && sname != DefaultSection {
- buf.WriteString(indent)
- }
-
switch {
case key.isAutoIncrement:
kname = "-"
@@ -445,6 +469,9 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
}
writeKeyValue := func(val string) (bool, error) {
+ if len(indent) > 0 && sname != DefaultSection {
+ buf.WriteString(indent)
+ }
if _, err := buf.WriteString(kname); err != nil {
return false, err
}
@@ -464,8 +491,18 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
val = `"""` + val + `"""`
} else if !f.options.IgnoreInlineComment && strings.ContainsAny(val, "#;") {
val = "`" + val + "`"
+ } else if (!f.options.PreserveSurroundedQuote &&
+ (hasSurroundedQuote(val, '"') || hasSurroundedQuote(val, '\''))) ||
+ strings.HasPrefix(val, `"""`) {
+ // Reader would unquote these or read them as a wrapper, so escape.
+ val = "`" + val + "`"
} else if len(strings.TrimSpace(val)) != len(val) {
- val = `"` + val + `"`
+ if strings.Contains(val, `"`) {
+ // Reader can't strip "..." with an inner quote; wrap raw instead.
+ val = "`" + val + "`"
+ } else {
+ val = `"` + val + `"`
+ }
}
if _, err := buf.WriteString(equalSign + val + LineBreak); err != nil {
return false, err
@@ -496,6 +533,10 @@ func (f *File) writeToBuffer(indent string) (*bytes.Buffer, error) {
}
}
+ if err := writeCommentLines(buf, sec.TrailingComment, ""); err != nil {
+ return nil, err
+ }
+
if PrettySection && !isLastSection {
// Put a line between sections
if _, err := buf.WriteString(LineBreak); err != nil {
@@ -532,7 +573,7 @@ func (f *File) SaveToIndent(filename, indent string) error {
return err
}
- return ioutil.WriteFile(filename, buf.Bytes(), 0666)
+ return os.WriteFile(filename, buf.Bytes(), 0666)
}
// SaveTo writes content to file system.
diff --git a/vendor/gopkg.in/ini.v1/helper.go b/vendor/gopkg.in/ini.v1/helper.go
@@ -1,24 +0,0 @@
-// Copyright 2019 Unknwon
-//
-// Licensed under the Apache License, Version 2.0 (the "License"): you may
-// not use this file except in compliance with the License. You may obtain
-// a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
-// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
-// License for the specific language governing permissions and limitations
-// under the License.
-
-package ini
-
-func inSlice(str string, s []string) bool {
- for _, v := range s {
- if str == v {
- return true
- }
- }
- return false
-}
diff --git a/vendor/gopkg.in/ini.v1/ini.go b/vendor/gopkg.in/ini.v1/ini.go
@@ -125,6 +125,16 @@ type LoadOptions struct {
AllowNonUniqueSections bool
// AllowDuplicateShadowValues indicates whether values for shadowed keys should be deduplicated.
AllowDuplicateShadowValues bool
+ // PreserveEmptyShadowValues indicates whether ValueWithShadows should keep
+ // empty values, and not deduplicate them, as systemd unit files use an
+ // empty assignment to reset prior values. Empty values are otherwise
+ // omitted.
+ PreserveEmptyShadowValues bool
+ // EscapeSliceDelimiters indicates whether ReflectFrom escapes backslashes
+ // and the delimiter in the elements of a string slice, so Key.Strings and
+ // MapTo read back the same elements. Other INI readers may not unescape
+ // them, so it is off by default.
+ EscapeSliceDelimiters bool
}
// DebugFunc is the type of function called to log parse events.
diff --git a/vendor/gopkg.in/ini.v1/key.go b/vendor/gopkg.in/ini.v1/key.go
@@ -15,12 +15,12 @@
package ini
import (
- "bytes"
"errors"
"fmt"
"strconv"
"strings"
"time"
+ "unicode/utf8"
)
// Key represents a key under a section.
@@ -54,8 +54,10 @@ func (k *Key) addShadow(val string) error {
return errors.New("cannot add shadow to auto-increment or boolean key")
}
- if !k.s.f.options.AllowDuplicateShadowValues {
- // Deduplicate shadows based on their values.
+ // Deduplicate shadows based on their values. A kept empty value is a
+ // reset, so each one counts.
+ keepEmpty := val == "" && k.s.f.options.PreserveEmptyShadowValues
+ if !k.s.f.options.AllowDuplicateShadowValues && !keepEmpty {
if k.value == val {
return nil
}
@@ -110,22 +112,23 @@ func (k *Key) Value() string {
return k.value
}
-// ValueWithShadows returns raw values of key and its shadows if any. Shadow
-// keys with empty values are ignored from the returned list.
+// ValueWithShadows returns raw values of key and its shadows if any.
+// Empty values are omitted unless LoadOptions.PreserveEmptyShadowValues is set.
func (k *Key) ValueWithShadows() []string {
+ keepEmpty := k.s.f.options.PreserveEmptyShadowValues
if len(k.shadows) == 0 {
- if k.value == "" {
+ if k.value == "" && !keepEmpty {
return []string{}
}
return []string{k.value}
}
vals := make([]string, 0, len(k.shadows)+1)
- if k.value != "" {
+ if k.value != "" || keepEmpty {
vals = append(vals, k.value)
}
for _, s := range k.shadows {
- if s.value != "" {
+ if s.value != "" || keepEmpty {
vals = append(vals, s.value)
}
}
@@ -140,14 +143,26 @@ func (k *Key) NestedValues() []string {
// transformValue takes a raw value and transforms to its final string.
func (k *Key) transformValue(val string) string {
+ res, _ := k.transformValueWithVisited(val, nil)
+ return res
+}
+
+func (k *Key) transformValueWithVisited(val string, visited map[*Key]struct{}) (string, bool) {
if k.s.f.ValueMapper != nil {
val = k.s.f.ValueMapper(val)
}
// Fail-fast if no indicate char found for recursive value
if !strings.Contains(val, "%") {
- return val
+ return val, false
}
+
+ if visited == nil {
+ visited = make(map[*Key]struct{})
+ }
+ visited[k] = struct{}{}
+ defer delete(visited, k)
+
for i := 0; i < depthValues; i++ {
vr := varPattern.FindString(val)
if len(vr) == 0 {
@@ -167,12 +182,25 @@ func (k *Key) transformValue(val string) string {
// and returns the value as-is.
break
}
+ if nk == k {
+ // Stop when key references itself to prevent cycle.
+ return val, true
+ }
+ }
+
+ if _, ok := visited[nk]; ok {
+ return val, true
+ }
+
+ newVal, hasCycle := nk.transformValueWithVisited(nk.value, visited)
+ if hasCycle {
+ return val, true
}
// Substitute by new value and take off leading '%(' and trailing ')s'.
- val = strings.ReplaceAll(val, vr, nk.value)
+ val = strings.ReplaceAll(val, vr, newVal)
}
- return val
+ return val, false
}
// String returns string representation of value.
@@ -488,6 +516,16 @@ func (k *Key) RangeTime(defaultVal, min, max time.Time) time.Time {
return k.RangeTimeFormat(time.RFC3339, defaultVal, min, max)
}
+// escapeDelimited prepares a slice element for joining with delim.
+// Backslashes are escaped first, then occurrences of delim, matching Strings().
+func escapeDelimited(val, delim string) string {
+ if delim == "" {
+ return val
+ }
+ val = strings.ReplaceAll(val, `\`, `\\`)
+ return strings.ReplaceAll(val, delim, `\`+delim)
+}
+
// Strings returns list of string divided by given delimiter.
func (k *Key) Strings(delim string) []string {
str := k.String()
@@ -495,31 +533,38 @@ func (k *Key) Strings(delim string) []string {
return []string{}
}
- runes := []rune(str)
- vals := make([]string, 0, 2)
- var buf bytes.Buffer
- escape := false
- idx := 0
+ maxParts := strings.Count(str, delim) + 1
+ vals := make([]string, 0, maxParts)
+
+ var buf strings.Builder
+ buf.Grow(len(str))
+
+ i := 0
for {
- if escape {
- escape = false
- if runes[idx] != '\\' && !strings.HasPrefix(string(runes[idx:]), delim) {
+ if str[i] == '\\' {
+ i++
+ if i >= len(str) {
+ break
+ }
+
+ if str[i] != '\\' && !strings.HasPrefix(str[i:], delim) {
buf.WriteRune('\\')
}
- buf.WriteRune(runes[idx])
+
+ r, size := utf8.DecodeRuneInString(str[i:])
+ i += size
+ buf.WriteRune(r)
+ } else if strings.HasPrefix(str[i:], delim) {
+ i += len(delim)
+ vals = append(vals, strings.TrimSpace(buf.String()))
+ buf.Reset()
} else {
- if runes[idx] == '\\' {
- escape = true
- } else if strings.HasPrefix(string(runes[idx:]), delim) {
- idx += len(delim) - 1
- vals = append(vals, strings.TrimSpace(buf.String()))
- buf.Reset()
- } else {
- buf.WriteRune(runes[idx])
- }
+ r, size := utf8.DecodeRuneInString(str[i:])
+ i += size
+ buf.WriteRune(r)
}
- idx++
- if idx == len(runes) {
+
+ if i >= len(str) {
break
}
}
@@ -833,5 +878,8 @@ func (k *Key) SetValue(v string) {
}
k.value = v
- k.s.keysHash[k.name] = v
+ // The Key Section.Key returns for an empty name isn't in the section.
+ if k.name != "" {
+ k.s.keysHash[k.name] = v
+ }
}
diff --git a/vendor/gopkg.in/ini.v1/parser.go b/vendor/gopkg.in/ini.v1/parser.go
@@ -73,36 +73,42 @@ func newParser(r io.Reader, opts parserOptions) *parser {
// BOM handles header of UTF-8, UTF-16 LE and UTF-16 BE's BOM format.
// http://en.wikipedia.org/wiki/Byte_order_mark#Representations_of_byte_order_marks_by_encoding
func (p *parser) BOM() error {
- mask, err := p.buf.Peek(2)
- if err != nil && err != io.EOF {
- return err
- } else if len(mask) < 2 {
- return nil
- }
-
- switch {
- case mask[0] == 254 && mask[1] == 255:
- fallthrough
- case mask[0] == 255 && mask[1] == 254:
- _, err = p.buf.Read(mask)
- if err != nil {
- return err
- }
- case mask[0] == 239 && mask[1] == 187:
- mask, err := p.buf.Peek(3)
+ // Strip every leading BOM: a file may accidentally carry more than one
+ // (e.g. a tool prepending a BOM to already-BOM'd content). Stopping after
+ // the first one leaves the remaining BOM on the next token and makes the
+ // parser fail with a misleading "key-value delimiter not found" (#390).
+ for {
+ mask, err := p.buf.Peek(2)
if err != nil && err != io.EOF {
return err
- } else if len(mask) < 3 {
+ } else if len(mask) < 2 {
return nil
}
- if mask[2] == 191 {
- _, err = p.buf.Read(mask)
- if err != nil {
+
+ switch {
+ case mask[0] == 254 && mask[1] == 255:
+ fallthrough
+ case mask[0] == 255 && mask[1] == 254:
+ if _, err = p.buf.Read(mask); err != nil {
+ return err
+ }
+ case mask[0] == 239 && mask[1] == 187:
+ mask, err := p.buf.Peek(3)
+ if err != nil && err != io.EOF {
return err
+ } else if len(mask) < 3 {
+ return nil
}
+ if mask[2] != 191 {
+ return nil
+ }
+ if _, err = p.buf.Read(mask); err != nil {
+ return err
+ }
+ default:
+ return nil
}
}
- return nil
}
func (p *parser) readUntil(delim byte) ([]byte, error) {
@@ -225,6 +231,42 @@ func (p *parser) readContinuationLines(val string) (string, error) {
return val, nil
}
+func inlineCommentIndex(line string, spaceBefore bool) int {
+ var quote byte
+ escaped := false
+ for i := 0; i < len(line); i++ {
+ ch := line[i]
+ if quote != 0 {
+ if escaped {
+ escaped = false
+ continue
+ }
+ if quote == '"' && ch == '\\' {
+ escaped = true
+ continue
+ }
+ if ch == quote {
+ quote = 0
+ }
+ continue
+ }
+ if i == 0 && (ch == '\'' || ch == '"') {
+ quote = ch
+ continue
+ }
+ if ch != '#' && ch != ';' {
+ continue
+ }
+ if !spaceBefore {
+ return i
+ }
+ if i > 0 && line[i-1] == ' ' {
+ return i - 1
+ }
+ }
+ return -1
+}
+
// hasSurroundedQuote check if and only if the first and last characters
// are quotes \" or \'.
// It returns false if any other parts also contain same kind of quotes.
@@ -276,24 +318,13 @@ func (p *parser) readValue(in []byte, bufferSize int) (string, error) {
return p.readContinuationLines(line[:len(line)-1])
}
- // Check if ignore inline comment
+ // Check for inline comments only outside a value's surrounding quotes.
if !p.options.IgnoreInlineComment {
- var i int
- if p.options.SpaceBeforeInlineComment {
- i = strings.Index(line, " #")
- if i == -1 {
- i = strings.Index(line, " ;")
- }
-
- } else {
- i = strings.IndexAny(line, "#;")
- }
-
+ i := inlineCommentIndex(line, p.options.SpaceBeforeInlineComment)
if i > -1 {
p.comment.WriteString(line[i:])
line = strings.TrimSpace(line[:i])
}
-
}
// Trim single and double quotes
@@ -461,6 +492,7 @@ func (f *File) parse(reader io.Reader) (err error) {
if f.options.UnparseableSections[i] == name ||
((f.options.Insensitive || f.options.InsensitiveSections) && strings.EqualFold(f.options.UnparseableSections[i], name)) {
inUnparseableSection = true
+ section.isRawSection = true
continue
}
}
@@ -468,7 +500,6 @@ func (f *File) parse(reader io.Reader) (err error) {
}
if inUnparseableSection {
- section.isRawSection = true
section.rawBody += string(line)
continue
}
@@ -524,5 +555,11 @@ func (f *File) parse(reader io.Reader) (err error) {
p.comment.Reset()
lastRegularKey = key
}
+ // Comments after the last key/section are otherwise dropped on EOF
+ // (e.g. Ansible blockinfile # END markers). Keep them on the last section.
+ if p.comment.Len() > 0 {
+ section.TrailingComment = strings.TrimSpace(p.comment.String())
+ p.comment.Reset()
+ }
return nil
}
diff --git a/vendor/gopkg.in/ini.v1/section.go b/vendor/gopkg.in/ini.v1/section.go
@@ -22,12 +22,17 @@ import (
// Section represents a config section.
type Section struct {
- f *File
- Comment string
- name string
- keys map[string]*Key
- keyList []string
- keysHash map[string]string
+ f *File
+ Comment string
+ // TrailingComment is comments after the last key of this section
+ // (or after a raw section body) through EOF. Comments that sit
+ // immediately before the next [section] still attach to that next
+ // section's Comment, matching existing parse behavior.
+ TrailingComment string
+ name string
+ keys map[string]*Key
+ keyList []string
+ keysHash map[string]string
isRawSection bool
rawBody string
@@ -75,7 +80,7 @@ func (s *Section) NewKey(name, val string) (*Key, error) {
defer s.f.lock.Unlock()
}
- if inSlice(name, s.keyList) {
+ if _, ok := s.keys[name]; ok {
if s.f.options.AllowShadows {
if err := s.keys[name].addShadow(val); err != nil {
return nil, err
@@ -131,7 +136,7 @@ func (s *Section) GetKey(name string) (*Key, error) {
}
break
}
- return nil, fmt.Errorf("error when getting key of section %q: key %q not exists", s.name, name)
+ return nil, fmt.Errorf("error when getting key of section %q: key %q does not exist", s.name, name)
}
return key, nil
}
@@ -163,12 +168,17 @@ func (s *Section) HasValue(value string) bool {
}
// Key assumes named Key exists in section and returns a zero-value when not.
+// For an empty name, the returned Key is not part of the section, so setting
+// its value changes nothing in the section.
func (s *Section) Key(name string) *Key {
key, err := s.GetKey(name)
if err != nil {
- // It's OK here because the only possible error is empty key name,
- // but if it's empty, this piece of code won't be executed.
- key, _ = s.NewKey(name, "")
+ key, err = s.NewKey(name, "")
+ if err != nil {
+ // NewKey rejects empty names. Still honor the zero-value
+ // contract so Key("") is not nil.
+ return newKey(s, name, "")
+ }
return key
}
return key
@@ -226,6 +236,10 @@ func (s *Section) KeysHash() map[string]string {
// DeleteKey deletes a key from section.
func (s *Section) DeleteKey(name string) {
+ if s.f.options.Insensitive || s.f.options.InsensitiveKeys {
+ name = strings.ToLower(name)
+ }
+
if s.f.BlockMode {
s.f.lock.Lock()
defer s.f.lock.Unlock()
diff --git a/vendor/gopkg.in/ini.v1/struct.go b/vendor/gopkg.in/ini.v1/struct.go
@@ -94,7 +94,13 @@ func setSliceWithProperType(key *Key, field reflect.Value, delim string, allowSh
var vals interface{}
var err error
- sliceOf := field.Type().Elem().Kind()
+ elemType := field.Type().Elem()
+ isPtrElem := elemType.Kind() == reflect.Pointer
+ valueType := elemType
+ if isPtrElem {
+ valueType = elemType.Elem()
+ }
+ sliceOf := valueType.Kind()
switch sliceOf {
case reflect.String:
vals = strs
@@ -113,7 +119,7 @@ func setSliceWithProperType(key *Key, field reflect.Value, delim string, allowSh
case reflectTime:
vals, err = key.parseTimesFormat(time.RFC3339, strs, true, false)
default:
- return fmt.Errorf("unsupported type '[]%s'", sliceOf)
+ return fmt.Errorf("unsupported type '[]%s'", field.Type().Elem().Kind())
}
if err != nil && isStrict {
return err
@@ -121,23 +127,32 @@ func setSliceWithProperType(key *Key, field reflect.Value, delim string, allowSh
slice := reflect.MakeSlice(field.Type(), numVals, numVals)
for i := 0; i < numVals; i++ {
+ var v interface{}
switch sliceOf {
case reflect.String:
- slice.Index(i).Set(reflect.ValueOf(vals.([]string)[i]))
+ v = vals.([]string)[i]
case reflect.Int:
- slice.Index(i).Set(reflect.ValueOf(vals.([]int)[i]))
+ v = vals.([]int)[i]
case reflect.Int64:
- slice.Index(i).Set(reflect.ValueOf(vals.([]int64)[i]))
+ v = vals.([]int64)[i]
case reflect.Uint:
- slice.Index(i).Set(reflect.ValueOf(vals.([]uint)[i]))
+ v = vals.([]uint)[i]
case reflect.Uint64:
- slice.Index(i).Set(reflect.ValueOf(vals.([]uint64)[i]))
+ v = vals.([]uint64)[i]
case reflect.Float64:
- slice.Index(i).Set(reflect.ValueOf(vals.([]float64)[i]))
+ v = vals.([]float64)[i]
case reflect.Bool:
- slice.Index(i).Set(reflect.ValueOf(vals.([]bool)[i]))
+ v = vals.([]bool)[i]
case reflectTime:
- slice.Index(i).Set(reflect.ValueOf(vals.([]time.Time)[i]))
+ v = vals.([]time.Time)[i]
+ }
+ rv := reflect.ValueOf(v)
+ if isPtrElem {
+ pv := reflect.New(rv.Type())
+ pv.Elem().Set(rv)
+ slice.Index(i).Set(pv)
+ } else {
+ slice.Index(i).Set(rv)
}
}
field.Set(slice)
@@ -156,7 +171,7 @@ func wrapStrictError(err error, isStrict bool) error {
// because we want to use default value that is already assigned to struct.
func setWithProperType(t reflect.Type, key *Key, field reflect.Value, delim string, allowShadow, isStrict bool) error {
vt := t
- isPtr := t.Kind() == reflect.Ptr
+ isPtr := t.Kind() == reflect.Pointer
if isPtr {
vt = t.Elem()
}
@@ -278,7 +293,7 @@ func parseTagOptions(tag string) (rawName string, omitEmpty bool, allowShadow bo
// mapToField maps the given value to the matching field of the given section.
// The sectionIndex is the index (if non unique sections are enabled) to which the value should be added.
func (s *Section) mapToField(val reflect.Value, isStrict bool, sectionIndex int, sectionName string) error {
- if val.Kind() == reflect.Ptr {
+ if val.Kind() == reflect.Pointer {
val = val.Elem()
}
typ := val.Type()
@@ -299,8 +314,8 @@ func (s *Section) mapToField(val reflect.Value, isStrict bool, sectionIndex int,
}
isStruct := tpField.Type.Kind() == reflect.Struct
- isStructPtr := tpField.Type.Kind() == reflect.Ptr && tpField.Type.Elem().Kind() == reflect.Struct
- isAnonymousPtr := tpField.Type.Kind() == reflect.Ptr && tpField.Anonymous
+ isStructPtr := tpField.Type.Kind() == reflect.Pointer && tpField.Type.Elem().Kind() == reflect.Struct
+ isAnonymousPtr := tpField.Type.Kind() == reflect.Pointer && tpField.Anonymous
if isAnonymousPtr {
field.Set(reflect.New(tpField.Type.Elem()))
}
@@ -358,21 +373,33 @@ func (s *Section) mapToField(val reflect.Value, isStrict bool, sectionIndex int,
}
// mapToSlice maps all sections with the same name and returns the new value.
-// The type of the Value must be a slice.
+// The type of the Value must be a slice of structs or pointers to structs.
func (s *Section) mapToSlice(secName string, val reflect.Value, isStrict bool) (reflect.Value, error) {
secs, err := s.f.SectionsByName(secName)
if err != nil {
return reflect.Value{}, err
}
- typ := val.Type().Elem()
+ elemType := val.Type().Elem()
+ isPtr := elemType.Kind() == reflect.Pointer
+ structType := elemType
+ if isPtr {
+ if elemType.Elem().Kind() != reflect.Struct {
+ return reflect.Value{}, fmt.Errorf("slice of pointers to non-struct type %s", elemType)
+ }
+ structType = elemType.Elem()
+ }
+
for i, sec := range secs {
- elem := reflect.New(typ)
+ elem := reflect.New(structType)
if err = sec.mapToField(elem, isStrict, i, sec.name); err != nil {
return reflect.Value{}, fmt.Errorf("map to field from section %q: %v", secName, err)
}
-
- val = reflect.Append(val, elem.Elem())
+ if isPtr {
+ val = reflect.Append(val, elem)
+ } else {
+ val = reflect.Append(val, elem.Elem())
+ }
}
return val, nil
}
@@ -381,13 +408,21 @@ func (s *Section) mapToSlice(secName string, val reflect.Value, isStrict bool) (
func (s *Section) mapTo(v interface{}, isStrict bool) error {
typ := reflect.TypeOf(v)
val := reflect.ValueOf(v)
- if typ.Kind() == reflect.Ptr {
+ if typ == nil || !val.IsValid() {
+ return errors.New("nil pointer to a struct")
+ }
+ if typ.Kind() == reflect.Pointer {
typ = typ.Elem()
val = val.Elem()
} else {
return errors.New("not a pointer to a struct")
}
+ // MapTo(&cfg) where cfg is a nil *T used to panic in mapToField (#369).
+ if !val.IsValid() || (val.Kind() == reflect.Pointer && val.IsNil()) {
+ return errors.New("nil pointer to a struct")
+ }
+
if typ.Kind() == reflect.Slice {
newField, err := s.mapToSlice(s.name, val, isStrict)
if err != nil {
@@ -498,15 +533,19 @@ func reflectSliceWithProperType(key *Key, field reflect.Value, delim string, all
for i := 0; i < field.Len(); i++ {
switch sliceOf {
case reflect.String:
- buf.WriteString(slice.Index(i).String())
+ val := slice.Index(i).String()
+ if key.s.f.options.EscapeSliceDelimiters {
+ val = escapeDelimited(val, delim)
+ }
+ buf.WriteString(val)
case reflect.Int, reflect.Int64:
- buf.WriteString(fmt.Sprint(slice.Index(i).Int()))
+ fmt.Fprint(&buf, slice.Index(i).Int())
case reflect.Uint, reflect.Uint64:
- buf.WriteString(fmt.Sprint(slice.Index(i).Uint()))
+ fmt.Fprint(&buf, slice.Index(i).Uint())
case reflect.Float64:
- buf.WriteString(fmt.Sprint(slice.Index(i).Float()))
+ fmt.Fprint(&buf, slice.Index(i).Float())
case reflect.Bool:
- buf.WriteString(fmt.Sprint(slice.Index(i).Bool()))
+ fmt.Fprint(&buf, slice.Index(i).Bool())
case reflectTime:
buf.WriteString(slice.Index(i).Interface().(time.Time).Format(time.RFC3339))
default:
@@ -535,7 +574,7 @@ func reflectWithProperType(t reflect.Type, key *Key, field reflect.Value, delim
key.SetValue(fmt.Sprint(field.Interface().(time.Time).Format(time.RFC3339)))
case reflect.Slice:
return reflectSliceWithProperType(key, field, delim, allowShadow)
- case reflect.Ptr:
+ case reflect.Pointer:
if !field.IsNil() {
return reflectWithProperType(t.Elem(), key, field.Elem(), delim, allowShadow)
}
@@ -559,7 +598,7 @@ func isEmptyValue(v reflect.Value) bool {
return v.Uint() == 0
case reflect.Float32, reflect.Float64:
return v.Float() == 0
- case reflect.Interface, reflect.Ptr:
+ case reflect.Interface, reflect.Pointer:
return v.IsNil()
case reflectTime:
t, ok := v.Interface().(time.Time)
@@ -574,7 +613,7 @@ type StructReflector interface {
}
func (s *Section) reflectFrom(val reflect.Value) error {
- if val.Kind() == reflect.Ptr {
+ if val.Kind() == reflect.Pointer {
val = val.Elem()
}
typ := val.Type()
@@ -598,7 +637,10 @@ func (s *Section) reflectFrom(val reflect.Value) error {
}
if r, ok := field.Interface().(StructReflector); ok {
- return r.ReflectINIStruct(s.f)
+ if err := r.ReflectINIStruct(s.f); err != nil {
+ return err
+ }
+ continue
}
fieldName := s.parseFieldName(tpField.Name, rawName)
@@ -606,14 +648,14 @@ func (s *Section) reflectFrom(val reflect.Value) error {
continue
}
- if extends && tpField.Anonymous && (tpField.Type.Kind() == reflect.Ptr || tpField.Type.Kind() == reflect.Struct) {
+ if extends && tpField.Anonymous && (tpField.Type.Kind() == reflect.Pointer || tpField.Type.Kind() == reflect.Struct) {
if err := s.reflectFrom(field); err != nil {
return fmt.Errorf("reflect from field %q: %v", fieldName, err)
}
continue
}
- if (tpField.Type.Kind() == reflect.Ptr && tpField.Type.Elem().Kind() == reflect.Struct) ||
+ if (tpField.Type.Kind() == reflect.Pointer && tpField.Type.Elem().Kind() == reflect.Struct) ||
(tpField.Type.Kind() == reflect.Struct && tpField.Type.Name() != "Time") {
// Note: The only error here is section doesn't exist.
sec, err := s.f.GetSection(fieldName)
@@ -641,7 +683,7 @@ func (s *Section) reflectFrom(val reflect.Value) error {
sliceOf := field.Type().Elem().Kind()
for i := 0; i < field.Len(); i++ {
- if sliceOf != reflect.Struct && sliceOf != reflect.Ptr {
+ if sliceOf != reflect.Struct && sliceOf != reflect.Pointer {
return fmt.Errorf("field %q is not a slice of pointer or struct", fieldName)
}
@@ -688,11 +730,11 @@ func (s *Section) ReflectFrom(v interface{}) error {
val := reflect.ValueOf(v)
if s.name != DefaultSection && s.f.options.AllowNonUniqueSections &&
- (typ.Kind() == reflect.Slice || typ.Kind() == reflect.Ptr) {
+ (typ.Kind() == reflect.Slice || typ.Kind() == reflect.Pointer) {
// Clear sections to make sure none exists before adding the new ones
s.f.DeleteSection(s.name)
- if typ.Kind() == reflect.Ptr {
+ if typ.Kind() == reflect.Pointer {
sec, err := s.f.NewSection(s.name)
if err != nil {
return err
@@ -702,7 +744,7 @@ func (s *Section) ReflectFrom(v interface{}) error {
slice := val.Slice(0, val.Len())
sliceOf := val.Type().Elem().Kind()
- if sliceOf != reflect.Ptr {
+ if sliceOf != reflect.Pointer {
return fmt.Errorf("not a slice of pointers")
}
@@ -721,7 +763,7 @@ func (s *Section) ReflectFrom(v interface{}) error {
return nil
}
- if typ.Kind() == reflect.Ptr {
+ if typ.Kind() == reflect.Pointer {
val = val.Elem()
} else {
return errors.New("not a pointer to a struct")
diff --git a/vendor/modules.txt b/vendor/modules.txt
@@ -13,18 +13,18 @@ github.com/lib/pq/internal/proto
github.com/lib/pq/oid
github.com/lib/pq/pqerror
github.com/lib/pq/scram
-# github.com/schanzen/taler-go v1.5.2
+# github.com/schanzen/taler-go v1.6.0
## explicit; go 1.24.0
github.com/schanzen/taler-go/pkg/merchant
github.com/schanzen/taler-go/pkg/rest
github.com/schanzen/taler-go/pkg/util
-# golang.org/x/text v0.36.0
-## explicit; go 1.25.0
+# golang.org/x/text v0.44.0
+## explicit; go 1.26.0
golang.org/x/text/internal/language
golang.org/x/text/internal/language/compact
golang.org/x/text/internal/tag
golang.org/x/text/language
-# gopkg.in/ini.v1 v1.67.1
+# gopkg.in/ini.v1 v1.68.0
## explicit; go 1.13
gopkg.in/ini.v1
# rsc.io/getopt v0.0.0-20170811000552-20be20937449