ernie-research/MEnvData-SWE huggingface dataset:
Repository: pingcap/tidb (Go)

Issue:
Unnecessary "Binary_plan" field in the slow log
## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)

```sql
set global tidb_slow_log_threshold = 1;
create table t(a int, b int, index ia(a), index ib(b));
```
Then see the slow log.

### 2. What did you expect to see? (Required)

If the statement doesn't have a plan, we don't need to print the binary plan.

### 3. What did you see instead (Required)

In the slow log:
```
# Binary_plan: tidb_decode_binary_plan('')
```

An empty binary plan is printed.

### 4. What is your TiDB version? (Required)

6.2, master




Discussion:

Patch:
diff --git a/executor/adapter.go b/executor/adapter.go
index 430dae026582b..064074e8a44a8 100644
--- a/executor/adapter.go
+++ b/executor/adapter.go
@@ -1207,7 +1207,9 @@ func (a *ExecStmt) LogSlowQuery(txnTS uint64, succ bool, hasMoreResults bool) {
 	binaryPlan := ""
 	if variable.GenerateBinaryPlan.Load() {
 		binaryPlan = getBinaryPlan(a.Ctx)
-		binaryPlan = variable.SlowLogBinaryPlanPrefix + binaryPlan + variable.SlowLogPlanSuffix
+		if len(binaryPlan) > 0 {
+			binaryPlan = variable.SlowLogBinaryPlanPrefix + binaryPlan + variable.SlowLogPlanSuffix
+		}
 	}
 
 	resultRows := GetResultRowsCount(stmtCtx, a.Plan)


Test patch:
diff --git a/planner/core/binary_plan_test.go b/planner/core/binary_plan_test.go
index be8aadd6e7f4c..40abb5c62b493 100644
--- a/planner/core/binary_plan_test.go
+++ b/planner/core/binary_plan_test.go
@@ -17,6 +17,7 @@ package core_test
 import (
 	"encoding/base64"
 	"fmt"
+	"io/ioutil"
 	"os"
 	"regexp"
 	"strings"
@@ -502,3 +503,32 @@ func TestInvalidDecodeBinaryPlan(t *testing.T) {
 	tk.MustQuery(`select tidb_decode_binary_plan('` + str3 + `')`).Check(testkit.Rows(""))
 	tk.MustQuery("show warnings").Check(testkit.Rows("Warning 1105 proto: illegal wireType 7"))
 }
+
+func TestUnnecessaryBinaryPlanInSlowLog(t *testing.T) {
+	store, clean := testkit.CreateMockStore(t)
+	defer clean()
+	tk := testkit.NewTestKit(t, store)
+	require.True(t, tk.Session().Auth(&auth.UserIdentity{Username: "root", Hostname: "%"}, nil, nil))
+
+	originCfg := config.GetGlobalConfig()
+	newCfg := *originCfg
+	f, err := os.CreateTemp("", "tidb-slow-*.log")
+	require.NoError(t, err)
+	newCfg.Log.SlowQueryFile = f.Name()
+	config.StoreGlobalConfig(&newCfg)
+	defer func() {
+		config.StoreGlobalConfig(originCfg)
+		require.NoError(t, f.Close())
+		require.NoError(t, os.Remove(newCfg.Log.SlowQueryFile))
+	}()
+	require.NoError(t, logutil.InitLogger(newCfg.Log.ToLogConfig()))
+	tk.MustExec(fmt.Sprintf("set @@tidb_slow_query_file='%v'", f.Name()))
+
+	tk.MustExec("use test")
+	tk.MustExec("drop table if exists th")
+	tk.MustExec("set global tidb_slow_log_threshold = 1;")
+	tk.MustExec("create table th (i int, a int,b int, c int, index (a)) partition by hash (a) partitions 100;")
+	slowLogBytes, err := ioutil.ReadAll(f)
+	require.NoError(t, err)
+	require.NotContains(t, string(slowLogBytes), `tidb_decode_binary_plan('')`)
+}
Repository: miniflux/v2 (Go)

Issue:
Posts written 17 days ago are labeled "3 weeks ago"
(miniflux is great, thanks!)

I think "3 weeks ago" is wrong in this case. I'd definitely prefer "17 days ago" -- which is what pinboard.in does. If I have starred a lot of items it's useful to know whether if it was published 14 days ago versus 20 days ago.


Discussion:
This is handled by the elapsedTime function, that does a fuzzy conversion based on how many days ago was the post published:

https://github.com/miniflux/miniflux/blob/b1e8f534eff7569dc2e8dab4dee851d1b709f71b/template/functions.go#L154-L176

I do think that this is simple enough for most use cases as a default behaviour. Would it be a solution for your use case to hover the fuzzy date? (it will show the full, properly formatted date).
I've been hovering over the fuzzy date. It's a bit of work, I'd rather not.

Here are options I'd prefer to the current behavior (in order of preference):
1. "17 days ago"
2. Change ``case d < 7`` to ``case d < 21``.
3. ``math.Round`` instead of ``math.Ceil``. Something posted 15 days ago is not posted "3 weeks ago". (And something posted 31 days ago is not posted two months ago.)

edit: add another option
What about sending a patch?



Patch:
diff --git a/template/functions.go b/template/functions.go
index 289de3df415..84a02f44083 100644
--- a/template/functions.go
+++ b/template/functions.go
@@ -162,16 +162,16 @@ func elapsedTime(printer *locale.Printer, tz string, t time.Time) string {
 		return printer.Plural("time_elapsed.hours", hours, hours)
 	case d == 1:
 		return printer.Printf("time_elapsed.yesterday")
-	case d < 7:
+	case d < 21:
 		return printer.Plural("time_elapsed.days", d, d)
 	case d < 31:
-		weeks := int(math.Ceil(float64(d) / 7))
+		weeks := int(math.Round(float64(d) / 7))
 		return printer.Plural("time_elapsed.weeks", weeks, weeks)
 	case d < 365:
-		months := int(math.Ceil(float64(d) / 30))
+		months := int(math.Round(float64(d) / 30))
 		return printer.Plural("time_elapsed.months", months, months)
 	default:
-		years := int(math.Ceil(float64(d) / 365))
+		years := int(math.Round(float64(d) / 365))
 		return printer.Plural("time_elapsed.years", years, years)
 	}
 }


Test patch:
diff --git a/template/functions_test.go b/template/functions_test.go
index 10d5535b7df..85c03c77528 100644
--- a/template/functions_test.go
+++ b/template/functions_test.go
@@ -111,7 +111,7 @@ func TestElapsedTime(t *testing.T) {
 		{time.Now().Add(-time.Hour * 3), printer.Plural("time_elapsed.hours", 3, 3)},
 		{time.Now().Add(-time.Hour * 32), printer.Printf("time_elapsed.yesterday")},
 		{time.Now().Add(-time.Hour * 24 * 3), printer.Plural("time_elapsed.days", 3, 3)},
-		{time.Now().Add(-time.Hour * 24 * 14), printer.Plural("time_elapsed.weeks", 2, 2)},
+		{time.Now().Add(-time.Hour * 24 * 14), printer.Plural("time_elapsed.days", 14, 14)},
 		{time.Now().Add(-time.Hour * 24 * 60), printer.Plural("time_elapsed.months", 2, 2)},
 		{time.Now().Add(-time.Hour * 24 * 365 * 3), printer.Plural("time_elapsed.years", 3, 3)},
 	}
Repository: pingcap/tidb (Go)

Issue:
Column.ResizeXxx has not correct nullBitmap
## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
util/chunk/column_test.go add ut:
```go
func Test_Column_ResizeInt64(t *testing.T) {
	var col = NewColumn(types.NewFieldType(mysql.TypeLonglong), 2)
	col.AppendUint64(11)
	col.AppendUint64(11)

	col.ResizeInt64(4, false)
	require.Equal(t, col.nullBitmap, 0b1111) // actually 0b11111111
	col.AppendUint64(11)
	require.Equal(t, col.nullBitmap, 0b11111) // actually 0b11111111
	col.AppendNull()
	require.Equal(t, col.nullBitmap, 0b011111) // actually 0b11111111
}
```

### 2. What did you expect to see? (Required)
pass ut

### 3. What did you see instead (Required)
fail

### 4. What is your TiDB version? (Required)
`a0e4ba9dc6119b1acac1c4496cf05c14484d3505`

planner: Reduce verbosity of logging unknown system variables (#36013)


<!-- Paste the output of SELECT tidb_version() -->




Discussion:

Patch:
diff --git a/util/chunk/column.go b/util/chunk/column.go
index 6fca6c89eecd0..0a48a1d6f97f7 100644
--- a/util/chunk/column.go
+++ b/util/chunk/column.go
@@ -333,13 +333,24 @@ func (c *Column) resize(n, typeSize int, isNull bool) {
 		newNulls = true
 	}
 	if !isNull || !newNulls {
-		var nullVal byte
+		var nullVal, lastByte byte
 		if !isNull {
 			nullVal = 0xFF
 		}
+
+		// Fill the null bitmap
 		for i := range c.nullBitmap {
 			c.nullBitmap[i] = nullVal
 		}
+		// Revise the last byte if necessary, when it's not divided by 8.
+		if x := (n % 8); x != 0 {
+			if !isNull {
+				lastByte = byte((1 << x) - 1)
+				if len(c.nullBitmap) > 0 {
+					c.nullBitmap[len(c.nullBitmap)-1] = lastByte
+				}
+			}
+		}
 	}
 
 	if cap(c.elemBuf) >= typeSize {


Test patch:
diff --git a/util/chunk/column_test.go b/util/chunk/column_test.go
index 98dd20322c5c6..df2481d5a1297 100644
--- a/util/chunk/column_test.go
+++ b/util/chunk/column_test.go
@@ -971,3 +971,26 @@ func BenchmarkMergeNullsNonVectorized(b *testing.B) {
 		}
 	}
 }
+
+func TestColumnResizeInt64(t *testing.T) {
+	var col = NewColumn(types.NewFieldType(mysql.TypeLonglong), 2)
+	col.AppendUint64(11)
+	col.AppendUint64(11)
+
+	col.ResizeInt64(4, false)
+	require.Equal(t, col.nullBitmap, []byte{0b1111})
+	col.AppendUint64(11)
+	require.Equal(t, col.nullBitmap, []byte{0b11111})
+	col.AppendNull()
+	require.Equal(t, col.nullBitmap, []byte{0b011111})
+
+	col.ResizeUint64(11, false)
+	require.Equal(t, col.nullBitmap, []byte{0b11111111, 0b111})
+
+	col.ResizeUint64(7, true)
+	require.Equal(t, col.nullBitmap, []byte{0})
+
+	col.AppendUint64(32)
+	col.AppendUint64(32)
+	require.Equal(t, col.nullBitmap, []byte{0b10000000, 0b1})
+}
Repository: pingcap/tidb (Go)

Issue:
handle unsigned value wrongly in `builtinCastIntAsDecimalSig`
## Bug Report

Please answer these questions before submitting your issue. Thanks!

1. What did you do?
If possible, provide a recipe for reproducing the error.
```
CREATE TABLE t1 (v bigint(20) UNSIGNED NOT NULL);
INSERT INTO t1 VALUES (1), (2);
SELECT SUM(IF(v > 1, v, -v)) FROM t1;
```

2. What did you expect to see?
```
1
```


3. What did you see instead?
```
+-----------------------+
| SUM(IF(v > 1, v, -v)) |
+-----------------------+
|  18446744073709551617 |
+-----------------------+
1 row in set (0.02 sec)
```


4. What version of TiDB are you using (`tidb-server -V` or run `select tidb_version();` on TiDB)?
```
+---------------------------------------------+
| version()                                   |
+---------------------------------------------+
| 5.7.25-TiDB-v4.0.0-alpha-5-g1c43f55f9-dirty |
+---------------------------------------------+
1 row in set (0.00 sec)

```



Discussion:

Patch:
diff --git a/expression/builtin_control.go b/expression/builtin_control.go
index 015f9705f2844..80e8d5e233e14 100644
--- a/expression/builtin_control.go
+++ b/expression/builtin_control.go
@@ -67,9 +67,8 @@ func InferType4ControlFuncs(lhs, rhs *types.FieldType) *types.FieldType {
 	} else if rhs.Tp == mysql.TypeNull {
 		*resultFieldType = *lhs
 	} else {
-		var unsignedFlag uint
-		evalType := types.AggregateEvalType([]*types.FieldType{lhs, rhs}, &unsignedFlag)
 		resultFieldType = types.AggFieldType([]*types.FieldType{lhs, rhs})
+		evalType := types.AggregateEvalType([]*types.FieldType{lhs, rhs}, &resultFieldType.Flag)
 		if evalType == types.ETInt {
 			resultFieldType.Decimal = 0
 		} else {


Test patch:
diff --git a/expression/integration_test.go b/expression/integration_test.go
index 52137a5096ac4..c35e1d8cdcfa5 100644
--- a/expression/integration_test.go
+++ b/expression/integration_test.go
@@ -4760,6 +4760,18 @@ func (s *testIntegrationSuite) TestFuncCaseWithLeftJoin(c *C) {
 	tk.MustQuery("select t1.id from kankan1 t1 left join kankan2 t2 on t1.id = t2.id where (case  when t1.name='b' then 'case2' when t1.name='a' then 'case1' else NULL end) = 'case1' order by t1.id").Check(testkit.Rows("1", "2"))
 }
 
+func (s *testIntegrationSuite) TestIssue11594(c *C) {
+	tk := testkit.NewTestKit(c, s.store)
+	tk.MustExec("use test")
+	tk.MustExec(`drop table if exists t1;`)
+	tk.MustExec("CREATE TABLE t1 (v bigint(20) UNSIGNED NOT NULL);")
+	tk.MustExec("INSERT INTO t1 VALUES (1), (2);")
+	tk.MustQuery("SELECT SUM(IF(v > 1, v, -v)) FROM t1;").Check(testkit.Rows("1"))
+	tk.MustQuery("SELECT sum(IFNULL(cast(null+rand() as unsigned), -v)) FROM t1;").Check(testkit.Rows("-3"))
+	tk.MustQuery("SELECT sum(COALESCE(cast(null+rand() as unsigned), -v)) FROM t1;").Check(testkit.Rows("-3"))
+	tk.MustQuery("SELECT sum(COALESCE(cast(null+rand() as unsigned), v)) FROM t1;").Check(testkit.Rows("3"))
+}
+
 func (s *testIntegrationSuite) TestIssue11309And11319(c *C) {
 	tk := testkit.NewTestKit(c, s.store)
 	tk.MustExec("use test")
Repository: uber-go/zap (Go)

Issue:
Add WithOptions() for SugaredLogger
Currently there is WithOptions() only for unsugared loggers, so Desugar() and then Sugar() needs to be called in order to add options to a SugaredLogger.


Discussion:
Hey @e-nikolov!
This is a reasonable request.
We'll be happy to review a PR for this.
Happy to give this a shot if that is okay?
> Happy to give this a shot if that is okay?

Oops, I missed this @craigpastro. Sure! Feel free to create a PR for this.
Thanks! Created a PR.



Patch:
diff --git a/sugar.go b/sugar.go
index 0b9651981..4f9d491a0 100644
--- a/sugar.go
+++ b/sugar.go
@@ -61,6 +61,16 @@ func (s *SugaredLogger) Named(name string) *SugaredLogger {
 	return &SugaredLogger{base: s.base.Named(name)}
 }
 
+// WithOptions clones the current SugaredLogger, applies the supplied Options,
+// and returns the result. It's safe to use concurrently.
+func (s *SugaredLogger) WithOptions(opts ...Option) *SugaredLogger {
+	base := s.base.clone()
+	for _, opt := range opts {
+		opt.apply(base)
+	}
+	return &SugaredLogger{base: base}
+}
+
 // With adds a variadic number of fields to the logging context. It accepts a
 // mix of strongly-typed Field objects and loosely-typed key-value pairs. When
 // processing pairs, the first element of the pair is used as the field key


Test patch:
diff --git a/sugar_test.go b/sugar_test.go
index 411759ad8..8cb0f9443 100644
--- a/sugar_test.go
+++ b/sugar_test.go
@@ -369,6 +369,22 @@ func TestSugarAddCallerFail(t *testing.T) {
 	})
 }
 
+func TestSugarWithOptionsIncreaseLevel(t *testing.T) {
+	withSugar(t, DebugLevel, nil, func(logger *SugaredLogger, logs *observer.ObservedLogs) {
+		logger = logger.WithOptions(IncreaseLevel(WarnLevel))
+		logger.Info("logger.Info")
+		logger.Warn("logger.Warn")
+		logger.Error("logger.Error")
+		require.Equal(t, 2, logs.Len(), "expected only warn + error logs due to IncreaseLevel.")
+		assert.Equal(
+			t,
+			logs.AllUntimed()[0].Message,
+			"logger.Warn",
+			"Expected first logged message to be warn level message",
+		)
+	})
+}
+
 func BenchmarkSugarSingleStrArg(b *testing.B) {
 	withSugar(b, InfoLevel, nil /* opts* */, func(log *SugaredLogger, logs *observer.ObservedLogs) {
 		for i := 0; i < b.N; i++ {
Repository: traefik/yaegi (Go)

Issue:
assign imported variable get type mismatch
The following program `sample.go` triggers a panic:

```go
package main

import (
	"fmt"
	"reflect"

	"github.com/traefik/yaegi/interp"
	"github.com/traefik/yaegi/stdlib"
)

const expression = `test_val == 11"`

func main() {
	i := interp.New(interp.Options{})
	i.Use(stdlib.Symbols)
	i.Use(interp.Exports{
		"mytest": {
			"test_val": reflect.ValueOf(int64(11)),
		},
	})
	init := `
import "mytest"

var test_val = mytest.test_val
`
	_, err := i.Eval(init)
	if err != nil {
		panic(err)
	}
	v, err := i.Eval(expression)
	if err != nil {
		panic(err)
	}
	fmt.Println(v.Interface().(bool))
}
```

Expected result:
```console
true
```

Got:
```console
4:5: panic
panic: reflect.Set: value of type int64 is not assignable to type int
```



Discussion:
It happens to me too...my go version is go1.14.2 darwin/amd64



Patch:
diff --git a/interp/cfg.go b/interp/cfg.go
index 3333a0db6..97a1a57d3 100644
--- a/interp/cfg.go
+++ b/interp/cfg.go
@@ -2570,11 +2570,7 @@ func isValueUntyped(v reflect.Value) bool {
 	if v.CanSet() {
 		return false
 	}
-	t := v.Type()
-	if t.Implements(constVal) {
-		return true
-	}
-	return t.String() == t.Kind().String()
+	return v.Type().Implements(constVal)
 }
 
 // isArithmeticAction returns true if the node action is an arithmetic operator.


Test patch:
diff --git a/interp/interp_eval_test.go b/interp/interp_eval_test.go
index 3b549e260..e6d895f00 100644
--- a/interp/interp_eval_test.go
+++ b/interp/interp_eval_test.go
@@ -103,6 +103,16 @@ func TestEvalStar(t *testing.T) {
 
 func TestEvalAssign(t *testing.T) {
 	i := interp.New(interp.Options{})
+	i.Use(interp.Exports{
+		"testpkg": {
+			"val": reflect.ValueOf(int64(11)),
+		},
+	})
+	_, e := i.Eval(`import "testpkg"`)
+	if e != nil {
+		t.Fatal(e)
+	}
+
 	runTests(t, i, []testCase{
 		{src: `a := "Hello"; a += " world"`, res: "Hello world"},
 		{src: `b := "Hello"; b += 1`, err: "1:42: invalid operation: mismatched types string and int"},
@@ -112,6 +122,7 @@ func TestEvalAssign(t *testing.T) {
 		{src: "g := 1; g <<= 8", res: "256"},
 		{src: "h := 1; h >>= 8", res: "0"},
 		{src: "i := 1; j := &i; (*j) = 2", res: "2"},
+		{src: "i64 := testpkg.val; i64 == 11", res: "true"},
 	})
 }
Repository: go-playground/validator (Go)

Issue:
Compare two booleans
### Package version
v9

### Question
Is there way to check that one of two booleans is true? I've tried through `nefield` tag and it seems does not compare booleans.

### Code sample, to showcase or reproduce:

```go
package main

import (
	"gopkg.in/go-playground/validator.v9"
	"fmt"
)

func main() {
	vd := validator.New()
	
	data := struct{
		RadioA bool `validate:"nefield=RadioB"`
		RadioB bool
	}{
		RadioA: true,
		RadioB: false,
	}
	
	err := vd.Struct(data)
	fmt.Println(err)
}
```



Discussion:

Patch:
diff --git a/baked_in.go b/baked_in.go
index 6ce762d15..bcb0fbb8f 100644
--- a/baked_in.go
+++ b/baked_in.go
@@ -791,6 +791,9 @@ func isNeField(fl FieldLevel) bool {
 	case reflect.Slice, reflect.Map, reflect.Array:
 		return int64(field.Len()) != int64(currentField.Len())
 
+	case reflect.Bool:
+		return field.Bool() != currentField.Bool()
+
 	case reflect.Struct:
 
 		fieldType := field.Type()


Test patch:
diff --git a/validator_test.go b/validator_test.go
index 683a2dddb..92a627453 100644
--- a/validator_test.go
+++ b/validator_test.go
@@ -4557,6 +4557,7 @@ func TestIsNeFieldValidation(t *testing.T) {
 	i := 1
 	j = 1
 	k = 1.543
+	b := true
 	arr := []string{"test"}
 	now := time.Now().UTC()
 
@@ -4566,6 +4567,7 @@ func TestIsNeFieldValidation(t *testing.T) {
 	i2 := 3
 	j2 = 2
 	k2 = 1.5434456
+	b2 := false
 	arr2 := []string{"test", "test2"}
 	arr3 := []string{"test"}
 	now2 := now
@@ -4582,6 +4584,9 @@ func TestIsNeFieldValidation(t *testing.T) {
 	errs = validate.VarWithValue(k2, k, "nefield")
 	Equal(t, errs, nil)
 
+	errs = validate.VarWithValue(b2, b, "nefield")
+	Equal(t, errs, nil)
+
 	errs = validate.VarWithValue(arr2, arr, "nefield")
 	Equal(t, errs, nil)
Repository: vmware-tanzu/velero (Go)

Issue:
The "--labels" option of "velero backup-location create" command doesn't work 
Get the following error when creating a BSL with `--labels` option:
```
An error occurred: invalid argument "a=c" for "--labels" flag: error parsing "a"
```
This is because the `Labels` field  isn't initialized [here](https://github.com/vmware-tanzu/velero/blob/main/pkg/cmd/cli/backuplocation/create.go#L78)


**Vote on this issue!**

This is an invitation to the Velero community to vote on issues, you can see the project's [top voted issues listed here](https://github.com/vmware-tanzu/velero/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).  
Use the "reaction smiley face" up to the right of this comment to vote.

- :+1: for "I would like to see this bug fixed as soon as possible"
- :-1: for "There are more important bugs to focus on right now"



Discussion:

Patch:
diff --git a/changelogs/unreleased/4491-ywk253100 b/changelogs/unreleased/4491-ywk253100
new file mode 100644
index 0000000000..5f8a3bff8b
--- /dev/null
+++ b/changelogs/unreleased/4491-ywk253100
@@ -0,0 +1,1 @@
+Initialize the labels field of `velero backup-location create` option to avoid #4484
\ No newline at end of file
diff --git a/pkg/cmd/cli/backuplocation/create.go b/pkg/cmd/cli/backuplocation/create.go
index d8403b8424..a90564be3a 100644
--- a/pkg/cmd/cli/backuplocation/create.go
+++ b/pkg/cmd/cli/backuplocation/create.go
@@ -78,6 +78,7 @@ func NewCreateOptions() *CreateOptions {
 	return &CreateOptions{
 		Credential: flag.NewMap(),
 		Config:     flag.NewMap(),
+		Labels:     flag.NewMap(),
 		AccessMode: flag.NewEnum(
 			string(velerov1api.BackupStorageLocationAccessModeReadWrite),
 			string(velerov1api.BackupStorageLocationAccessModeReadWrite),


Test patch:
diff --git a/pkg/cmd/cli/backuplocation/create_test.go b/pkg/cmd/cli/backuplocation/create_test.go
index 57977e7ea6..e09d452712 100644
--- a/pkg/cmd/cli/backuplocation/create_test.go
+++ b/pkg/cmd/cli/backuplocation/create_test.go
@@ -76,3 +76,14 @@ func TestBuildBackupStorageLocationSetsCredential(t *testing.T) {
 		Key:                  "key-from-secret",
 	}, bsl.Spec.Credential)
 }
+
+func TestBuildBackupStorageLocationSetsLabels(t *testing.T) {
+	o := NewCreateOptions()
+
+	err := o.Labels.Set("key=value")
+	assert.NoError(t, err)
+
+	bsl, err := o.BuildBackupStorageLocation("velero-test-ns", false, false)
+	assert.NoError(t, err)
+	assert.Equal(t, map[string]string{"key": "value"}, bsl.Labels)
+}
Repository: go-playground/validator (Go)

Issue:
Erroneous url_encoded validation
### Package version eg. v9, v10: 
v10

### Issue, Question or Enhancement:
Issue


### Code sample, to showcase or reproduce:

```go
	createOrganization := CreateOrganization{Organization: "hello"}
	err := validator.New().Struct(&createOrganization)
	if err != nil {
		var validationErrors validator.ValidationErrors
		var ok bool
		if validationErrors, ok = err.(validator.ValidationErrors); !ok {
			fmt.Println("non validation er")
			return
		}

		fmt.Printf("%v", validationErrors)
	} else {
		fmt.Printf("No validation error")
	}
```
Playground URL: https://play.golang.org/p/-awW91lwR-v 

If I use just english text, the above program should pass but it seem to fail. If I use an online url encoder program to encode an english text, I get the same input english text as the output. So the string `hello` should be considered as a valid url_encoded text.

However, if I use something else like `Hello+G%C3%BCnter` for the `Organization`, then the program works fine.


Discussion:
I agree, this seems like a bug.  I came here today to ask about this, guess I won't be using url_encoded
Thanks @psankar for reporting the validation is clearly not working as intended.

I will try to look at it as soon as I can but PR's to fix are also welcome.



Patch:
diff --git a/regexes.go b/regexes.go
index 9ecf4b1b4..ddcf785a4 100644
--- a/regexes.go
+++ b/regexes.go
@@ -45,7 +45,7 @@ const (
 	ethAddressRegexString            = `^0x[0-9a-fA-F]{40}$`
 	ethAddressUpperRegexString       = `^0x[0-9A-F]{40}$`
 	ethAddressLowerRegexString       = `^0x[0-9a-f]{40}$`
-	uRLEncodedRegexString            = `(%[A-Fa-f0-9]{2})`
+	uRLEncodedRegexString            = `^(?:[^%]|%[0-9A-Fa-f]{2})*$`
 	hTMLEncodedRegexString           = `&#[x]?([0-9a-fA-F]{2})|(&gt)|(&lt)|(&quot)|(&amp)+[;]?`
 	hTMLRegexString                  = `<[/]?([a-zA-Z]+).*?>`
 	splitParamsRegexString           = `'[^']*'|\S+`


Test patch:
diff --git a/validator_test.go b/validator_test.go
index db5bf739f..5dcd00ee0 100644
--- a/validator_test.go
+++ b/validator_test.go
@@ -9537,6 +9537,9 @@ func TestURLEncodedValidation(t *testing.T) {
 		{"a%b", false},
 		{"1%2", false},
 		{"%%a%%", false},
+		{"hello", true},
+		{"", true},
+		{"+", true},
 	}
 
 	validate := New()
Repository: pingcap/tidb (Go)

Issue:
Column count doesn't match value count when executing insert SQL using prepare + execute 
## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
create table t1 (a int(11) ,b varchar(100) ,primary key (a));
create table t2 (c int(11) ,d varchar(100) ,primary key (c));
prepare in1 from "insert into t1 (a,b) select c,null from t2 t on duplicate key update b=t.d" ;
execute in1 ;


### 2. What did you expect to see? (Required)
![a972ceb77a6fb7cf1874a2d89715cc2](https://user-images.githubusercontent.com/50732087/185281549-558ff1f1-9c02-421d-82ab-6bbb07f75498.jpg)


### 3. What did you see instead (Required)
![image](https://user-images.githubusercontent.com/50732087/185281629-57574730-8b5f-41ab-8574-15566e8d1ffb.png)


### 4. What is your TiDB version? (Required)
v5.3.2
v6.1.0




Discussion:
related to https://github.com/pingcap/tidb/pull/14412



Patch:
diff --git a/planner/core/planbuilder.go b/planner/core/planbuilder.go
index f00d0625c9cf0..14a9b169e5536 100644
--- a/planner/core/planbuilder.go
+++ b/planner/core/planbuilder.go
@@ -3895,6 +3895,11 @@ func (b *PlanBuilder) buildSelectPlanOfInsert(ctx context.Context, insert *ast.I
 					}
 					sel.Fields.Fields = append(sel.Fields.Fields, &ast.SelectField{Expr: colName, Offset: len(sel.Fields.Fields)})
 				}
+				defer func(originSelFieldLen int) {
+					// Revert the change for ast. Because when we use the 'prepare' and 'execute' statement it will both build plan which will cause problem.
+					// You can see the issue #37187 for more details.
+					sel.Fields.Fields = sel.Fields.Fields[:originSelFieldLen]
+				}(actualColLen)
 			}
 		}
 	}


Test patch:
diff --git a/executor/insert_test.go b/executor/insert_test.go
index d0d17199c13f7..06c9927bba008 100644
--- a/executor/insert_test.go
+++ b/executor/insert_test.go
@@ -352,6 +352,19 @@ func TestUpdateDuplicateKey(t *testing.T) {
 		"[kv:1062]Duplicate entry '1-2-4' for key 'PRIMARY'")
 }
 
+func TestIssue37187(t *testing.T) {
+	store := testkit.CreateMockStore(t)
+	tk := testkit.NewTestKit(t, store)
+	tk.MustExec("use test")
+
+	tk.MustExec("drop table if exists a, b")
+	tk.MustExec("create table t1 (a int(11) ,b varchar(100) ,primary key (a));")
+	tk.MustExec("create table t2 (c int(11) ,d varchar(100) ,primary key (c));")
+	tk.MustExec("prepare in1 from 'insert into t1 (a,b) select c,null from t2 t on duplicate key update b=t.d';")
+	err := tk.ExecToErr("execute in1;")
+	require.NoError(t, err)
+}
+
 func TestInsertWrongValueForField(t *testing.T) {
 	store := testkit.CreateMockStore(t)
 	tk := testkit.NewTestKit(t, store)
Repository: hashicorp/vault (Go)

Issue:
Vault v1.1.3 Breaks Compatibility for Consul Storage Config
**Describe the bug**
```
    storage "consul" {
      address = "unix:///consul-unix-socket/consul-client.sock"
      scheme = "http"
      disable_registration = "{{default "false" .Values.Vault.DisableConsulRegistration}}"
    }
```
Leads to:
`Error initializing storage of type consul: address should be host[:port], not URL`

That config has perfectly worked up until now (including in Vault v.1.1.2).



Discussion:
This is a regression I introduced; I can't find a quick workaround.  Altering the address so that it passes the check I added means it won't work with other components; for example, unix:/tmp/consul-client.sock isn't parsed by the client library.
@mgritter Thank you!!!



Patch:
diff --git a/physical/consul/consul.go b/physical/consul/consul.go
index e050cf08ee4..4db2b362875 100644
--- a/physical/consul/consul.go
+++ b/physical/consul/consul.go
@@ -237,9 +237,7 @@ func NewConsulBackend(conf map[string]string, logger log.Logger) (physical.Backe
 					logger.Debug("config address parsed", "scheme", parts[0])
 					logger.Debug("config scheme parsed", "address", parts[1])
 				}
-			} else {
-				return nil, errors.New("address should be host[:port], not URL")
-			}
+			} // allow "unix:" or whatever else consul supports in the future
 		}
 	}
 	if scheme, ok := conf["scheme"]; ok {


Test patch:
diff --git a/physical/consul/consul_test.go b/physical/consul/consul_test.go
index fa45f972f19..b474fb9ae5d 100644
--- a/physical/consul/consul_test.go
+++ b/physical/consul/consul_test.go
@@ -231,6 +231,24 @@ func TestConsul_newConsulBackend(t *testing.T) {
 			max_parallel:    4,
 			consistencyMode: "strong",
 		},
+		{
+			name: "Unix socket",
+			consulConfig: map[string]string{
+				"address": "unix:///tmp/.consul.http.sock",
+			},
+			address: "/tmp/.consul.http.sock",
+			scheme:  "http", // Default, not overridden?
+
+			// Defaults
+			checkTimeout:    5 * time.Second,
+			redirectAddr:    "http://127.0.0.1:8200",
+			path:            "vault/",
+			service:         "vault",
+			token:           "",
+			max_parallel:    4,
+			disableReg:      false,
+			consistencyMode: "default",
+		},
 		{
 			name: "Scheme in address",
 			consulConfig: map[string]string{
Repository: go-yaml/yaml (Go)

Issue:
float32 values like 0.99 are formatted incorrectly
While updating to the latest version, I noticed that float32 values like 0.01 and 0.99 are now formatted incorrectly.

E..g, test failure output for 0.99
```
-       weight: 0.99
+       weight: 0.9900000095367432
```

I think this is related to https://github.com/go-yaml/yaml/pull/314

I'm working on a fix.


Discussion:
Here's a playground showing how formatting float32 as float32 gives the correct result, but formatting a float32 as a float64 causes incorrect results:
https://play.golang.org/p/jbseI1ivyMW



Patch:
diff --git a/encode.go b/encode.go
index b3c62b39..a14435e8 100644
--- a/encode.go
+++ b/encode.go
@@ -333,7 +333,13 @@ func (e *encoder) timev(tag string, in reflect.Value) {
 }
 
 func (e *encoder) floatv(tag string, in reflect.Value) {
-	s := strconv.FormatFloat(in.Float(), 'g', -1, 64)
+	// Issue #352: When formatting, use the precision of the underlying value
+	precision := 64
+	if in.Kind() == reflect.Float32 {
+		precision = 32
+	}
+
+	s := strconv.FormatFloat(in.Float(), 'g', -1, precision)
 	switch s {
 	case "+Inf":
 		s = ".inf"


Test patch:
diff --git a/encode_test.go b/encode_test.go
index 0324a909..f0911a76 100644
--- a/encode_test.go
+++ b/encode_test.go
@@ -75,6 +75,9 @@ var marshalTests = []struct {
 	}, {
 		map[string]interface{}{"v": float64(0.1)},
 		"v: 0.1\n",
+	}, {
+		map[string]interface{}{"v": float32(0.99)},
+		"v: 0.99\n",
 	}, {
 		map[string]interface{}{"v": -0.1},
 		"v: -0.1\n",
Repository: traefik/yaegi (Go)

Issue:
wrong result of operations with an uint const
The following program `sample.go` triggers a wrong result:

```go
package main

func main() {
    const c uint = 2 + 8
    var a uint = 5 
    println(a + c)
}
```

Expected result:
```console
$ go run ./sample.go
15
```

Got:
```console
$ yaegi ./sample.go
5
```

This happens only with `uint` constant value, but for all operators, arithmetic and logic.


Discussion:

Patch:
diff --git a/interp/value.go b/interp/value.go
index d1dc47db7..adf5b60fa 100644
--- a/interp/value.go
+++ b/interp/value.go
@@ -342,6 +342,10 @@ func vInt(v reflect.Value) (i int64) {
 }
 
 func vUint(v reflect.Value) (i uint64) {
+	if c := vConstantValue(v); c != nil {
+		i, _ = constant.Uint64Val(constant.ToInt(c))
+		return i
+	}
 	switch v.Type().Kind() {
 	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
 		i = uint64(v.Int())


Test patch:
diff --git a/interp/interp_eval_test.go b/interp/interp_eval_test.go
index 2a1672488..5a7d4b4b9 100644
--- a/interp/interp_eval_test.go
+++ b/interp/interp_eval_test.go
@@ -82,6 +82,16 @@ func TestEvalShift(t *testing.T) {
 	})
 }
 
+func TestOpVarConst(t *testing.T) {
+	i := interp.New(interp.Options{})
+	runTests(t, i, []testCase{
+		{pre: func() { eval(t, i, "const a uint = 8 + 2") }, src: "a", res: "10"},
+		{src: "b := uint(5); a+b", res: "15"},
+		{src: "b := uint(5); b+a", res: "15"},
+		{src: "b := uint(5); b>a", res: "false"},
+	})
+}
+
 func TestEvalStar(t *testing.T) {
 	i := interp.New(interp.Options{})
 	runTests(t, i, []testCase{
Repository: vmware-tanzu/velero (Go)

Issue:
String format of namespace/resource excludes is incorrect when nothing is excluded
If we have an `IncludesExcludes` that excludes nothing, the formatted display of the excludes is `*`, e.g. `Excluding namespaces: *` from a backup log.

If we're excluding nothing, it should print `<none>` or `<n/a>` or something along those lines.


Discussion:

Patch:
diff --git a/pkg/util/collections/includes_excludes.go b/pkg/util/collections/includes_excludes.go
index c6d539d4ab..21df19491a 100644
--- a/pkg/util/collections/includes_excludes.go
+++ b/pkg/util/collections/includes_excludes.go
@@ -79,18 +79,18 @@ func (ie *IncludesExcludes) ShouldInclude(s string) bool {
 // IncludesString returns a string containing all of the includes, separated by commas, or * if the
 // list is empty.
 func (ie *IncludesExcludes) IncludesString() string {
-	return asString(ie.GetIncludes())
+	return asString(ie.GetIncludes(), "*")
 }
 
-// ExcludesString returns a string containing all of the excludes, separated by commas, or * if the
+// ExcludesString returns a string containing all of the excludes, separated by commas, or <none> if the
 // list is empty.
 func (ie *IncludesExcludes) ExcludesString() string {
-	return asString(ie.GetExcludes())
+	return asString(ie.GetExcludes(), "<none>")
 }
 
-func asString(in []string) string {
+func asString(in []string, empty string) string {
 	if len(in) == 0 {
-		return "*"
+		return empty
 	}
 	return strings.Join(in, ", ")
 }


Test patch:
diff --git a/pkg/util/collections/includes_excludes_test.go b/pkg/util/collections/includes_excludes_test.go
index 1f2bf30e88..905314dadd 100644
--- a/pkg/util/collections/includes_excludes_test.go
+++ b/pkg/util/collections/includes_excludes_test.go
@@ -135,3 +135,36 @@ func TestValidateIncludesExcludes(t *testing.T) {
 		})
 	}
 }
+
+func TestIncludeExcludeString(t *testing.T) {
+	tests := []struct {
+		name             string
+		includes         []string
+		excludes         []string
+		expectedIncludes string
+		expectedExcludes string
+	}{
+		{
+			name:             "unspecified includes/excludes should return '*'/'<none>'",
+			includes:         nil,
+			excludes:         nil,
+			expectedIncludes: "*",
+			expectedExcludes: "<none>",
+		},
+		{
+			name:             "specific resources should result in sorted joined string",
+			includes:         []string{"foo", "bar"},
+			excludes:         []string{"baz", "xyz"},
+			expectedIncludes: "bar, foo",
+			expectedExcludes: "baz, xyz",
+		},
+	}
+
+	for _, test := range tests {
+		t.Run(test.name, func(t *testing.T) {
+			ie := NewIncludesExcludes().Includes(test.includes...).Excludes(test.excludes...)
+			assert.Equal(t, test.expectedIncludes, ie.IncludesString())
+			assert.Equal(t, test.expectedExcludes, ie.ExcludesString())
+		})
+	}
+}
Repository: traefik/yaegi (Go)

Issue:
Interpreter.Eval fails if the last line of the input is a comment
If `Interpreter.Eval` is called with `s` and `s` is not terminated with a newline and the last line of `s` contains `//`, evaluation fails because the closing brace of the generated main function is commented out.

```go
package main

import "github.com/traefik/yaegi/interp"

func main() {
	i := interp.New(interp.Options{})
	_, err := i.Eval(`
		println("Hello world")
		// foo bar`)
	if err != nil {
		panic(err)
	}
}
```

Expected result:
```console
$ go run ./sample.go
Hello world
```

Got:
```console
$ go run ./sample.go
panic: _.go:3:14: expected '}', found 'EOF'

goroutine 1 [running]:
main.main()
        .../sample.go:11 +0xbb
exit status 2
```



Discussion:

Patch:
diff --git a/interp/ast.go b/interp/ast.go
index 966a5ab9a..8281631d2 100644
--- a/interp/ast.go
+++ b/interp/ast.go
@@ -357,7 +357,7 @@ func ignoreError(err error, src string) bool {
 }
 
 func wrapInMain(src string) string {
-	return fmt.Sprintf("package main; func main() {%s}", src)
+	return fmt.Sprintf("package main; func main() {%s\n}", src)
 }
 
 // Note: no type analysis is performed at this stage, it is done in pre-order


Test patch:
diff --git a/interp/interp_eval_test.go b/interp/interp_eval_test.go
index 31610387b..b97441a66 100644
--- a/interp/interp_eval_test.go
+++ b/interp/interp_eval_test.go
@@ -1504,3 +1504,10 @@ func TestStdio(t *testing.T) {
 		t.Fatalf("%v not *os.file", v.Interface())
 	}
 }
+
+func TestIssue1142(t *testing.T) {
+	i := interp.New(interp.Options{})
+	runTests(t, i, []testCase{
+		{src: "a := 1; // foo bar", res: "1"},
+	})
+}
Repository: pingcap/tidb (Go)

Issue:
lightning import failed due to sorted-kv-dir no such file or directory
## Bug Report

Please answer these questions before submitting your issue. Thanks!

### 1. Minimal reproduce step (Required)
1, run lighting to import test data,  specifying sorted-kv-dir = "/tmp/sorted-kv-dir"


### 2. What did you expect to see? (Required)
Lightning import expects to success.

### 3. What did you see instead (Required)
Lightning import fails due to below error 
```
/tmp # /tidb-lightning -config tidb-lightning.toml 
Verbose debug logs will be written to /tmp/lightning.log.2022-01-13T07.58.07Z

tidb lightning encountered error:  invalid tikv-importer.sorted-kv-dir: stat /tmp/sorted-kv-dir: no such file or directory

```

### 4. What is your TiDB version? (Required)
/tidb-lightning -V
Release Version: v5.4.0-nightly
Git Commit Hash: 794e838a1d9aac7531624d10c98ade610816c9e2
Git Branch: heads/refs/tags/v5.4.0-nightly
Go Version: go1.16.4
UTC Build Time: 2022-01-13 05:13:21
Race Enabled: false



Discussion:
Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.



Patch:
diff --git a/br/pkg/lightning/config/config.go b/br/pkg/lightning/config/config.go
index 09423a260e46c..1819e6528c060 100644
--- a/br/pkg/lightning/config/config.go
+++ b/br/pkg/lightning/config/config.go
@@ -949,6 +949,8 @@ func (cfg *Config) CheckAndAdjustForLocalBackend() error {
 	sortedKVDirInfo, err := os.Stat(storageSizeDir)
 
 	switch {
+	case os.IsNotExist(err):
+		return nil
 	case err == nil:
 		if !sortedKVDirInfo.IsDir() {
 			return errors.Errorf("tikv-importer.sorted-kv-dir ('%s') is not a directory", storageSizeDir)


Test patch:
diff --git a/br/pkg/lightning/config/config_test.go b/br/pkg/lightning/config/config_test.go
index 03d218036b535..a855be08190c2 100644
--- a/br/pkg/lightning/config/config_test.go
+++ b/br/pkg/lightning/config/config_test.go
@@ -23,6 +23,7 @@ import (
 	"net/http"
 	"net/http/httptest"
 	"net/url"
+	"os"
 	"path/filepath"
 	"regexp"
 	"strconv"
@@ -915,3 +916,27 @@ func (s configTestSuite) TestLoadCharsetFromConfig(c *C) {
 	_, err := config.ParseCharset("Unknown")
 	c.Assert(err, ErrorMatches, "found unsupported data-character-set: Unknown")
 }
+
+func (s *configTestSuite) TestCheckAndAdjustForLocalBackend(c *C) {
+	cfg := config.NewConfig()
+	assignMinimalLegalValue(cfg)
+
+	cfg.TikvImporter.Backend = config.BackendLocal
+	cfg.TikvImporter.SortedKVDir = ""
+	c.Assert(cfg.CheckAndAdjustForLocalBackend(), ErrorMatches, "tikv-importer.sorted-kv-dir must not be empty!")
+
+	// non exists dir is legal
+	cfg.TikvImporter.SortedKVDir = "./not-exists"
+	c.Assert(cfg.CheckAndAdjustForLocalBackend(), IsNil)
+
+	base := c.MkDir()
+	// create empty file
+	file := filepath.Join(base, "file")
+	c.Assert(os.WriteFile(file, []byte(""), 0644), IsNil)
+	cfg.TikvImporter.SortedKVDir = file
+	c.Assert(cfg.CheckAndAdjustForLocalBackend(), ErrorMatches, "tikv-importer.sorted-kv-dir (.*) is not a directory")
+
+	// legal dir
+	cfg.TikvImporter.SortedKVDir = base
+	c.Assert(cfg.CheckAndAdjustForLocalBackend(), IsNil)
+}
Repository: pion/webrtc (Go)

Issue:
PeerConnection doesn't close underlying ICEGatherer
### Your environment.
  - Version: 2.0.5
  - Browser: libwebrtc, iOS/Android

### What did you do?
Created a PeerConnection, exchanged offer/answer, iceConnectionState=checking, then close the PeerConnection before iceConnectionState=connected (there are no valid candidates due to an unrelated error).

### What did you expect?
The ICE agent to stop checking candidates

### What happened?
```js
{"level":"debug","scope":"ice","time":"2019-04-10T06:52:25Z","message":"pinging all candidates"}
{"level":"debug","scope":"ice","time":"2019-04-10T06:52:25Z","message":"ping STUN from host 10.8.0.51:47148 to relay 54.244.51.75:42834 related 0.0.0.0:0\n"}
{"level":"debug","scope":"ice","time":"2019-04-10T06:52:25Z","message":"ping STUN from srflx 34.66.185.1:54987 related 10.8.0.51:54987 to relay 54.244.51.75:42834 related 0.0.0.0:0\n"}
{"level":"debug","scope":"ice","time":"2019-04-10T06:52:27Z","message":"pinging all candidates"}
{"level":"debug","scope":"ice","time":"2019-04-10T06:52:27Z","message":"ping STUN from host 10.8.0.51:47148 to relay 54.244.51.75:42834 related 0.0.0.0:0\n"}
{"level":"debug","scope":"ice","time":"2019-04-10T06:52:27Z","message":"ping STUN from srflx 34.66.185.1:54987 related 10.8.0.51:54987 to relay 54.244.51.75:42834 related 0.0.0.0:0\n"}
```

The ICE agent continues pinging candidates every 2s until the program terminates.


Discussion:

Patch:
diff --git a/icetransport.go b/icetransport.go
index 328cbfd3c74..5ec7a097e49 100644
--- a/icetransport.go
+++ b/icetransport.go
@@ -148,7 +148,10 @@ func (t *ICETransport) Stop() error {
 
 	if t.mux != nil {
 		return t.mux.Close()
+	} else if t.gatherer != nil {
+		return t.gatherer.Close()
 	}
+
 	return nil
 }
 


Test patch:
diff --git a/peerconnection_close_test.go b/peerconnection_close_test.go
index 4a3c273c89f..68786e42163 100644
--- a/peerconnection_close_test.go
+++ b/peerconnection_close_test.go
@@ -55,3 +55,37 @@ func TestPeerConnection_Close(t *testing.T) {
 		t.Fatal(err)
 	}
 }
+
+// Assert that a PeerConnection that is shutdown before ICE starts doesn't leak
+func TestPeerConnection_Close_PreICE(t *testing.T) {
+	// Limit runtime in case of deadlocks
+	lim := test.TimeOut(time.Second * 20)
+	defer lim.Stop()
+
+	report := test.CheckRoutines(t)
+	defer report()
+
+	pcOffer, pcAnswer, err := newPair()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	answer, err := pcOffer.CreateOffer(nil)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	err = pcOffer.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	if err = pcAnswer.SetRemoteDescription(answer); err != nil {
+		t.Fatal(err)
+	}
+
+	err = pcAnswer.Close()
+	if err != nil {
+		t.Fatal(err)
+	}
+}
Repository: pingcap/tidb (Go)

Issue:
WalkDir of gcs only iterate at most 1000 keys
## Bug Report
ref

https://github.com/pingcap/tidb/blob/891517f23ec3443d971423d30d54feaa08fb51b3/br/pkg/storage/gcs.go#L183-L197

note `maxKeys` is 1000, and we will end the loop after iterate `maxKeys` keys
### 1. Minimal reproduce step (Required)
import data more than 1000 keys/files
<!-- a step by step guide for reproducing the bug. -->

### 2. What did you expect to see? (Required)
import all data under directory.
### 3. What did you see instead (Required)
only scan at most 1000 files
### 4. What is your TiDB version? (Required)

<!-- Paste the output of SELECT tidb_version() -->




Discussion:
`maxKeys` is 1000 only if `opt.ListCount` is left has default (0).
I think this do is a bug. For s3 the `maxKeys` is used to limit the fetch keys for each request but still ensure to visit all the keys. But gcs only visit `maxKeys` keys and then stop.
/cc @3pointer 
Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.



Patch:
diff --git a/br/pkg/storage/gcs.go b/br/pkg/storage/gcs.go
index 07ce5c8a862b9..e4835e0eb6111 100644
--- a/br/pkg/storage/gcs.go
+++ b/br/pkg/storage/gcs.go
@@ -180,11 +180,6 @@ func (s *gcsStorage) WalkDir(ctx context.Context, opt *WalkOption, fn func(strin
 		opt = &WalkOption{}
 	}
 
-	maxKeys := int64(1000)
-	if opt.ListCount > 0 {
-		maxKeys = opt.ListCount
-	}
-
 	prefix := path.Join(s.gcs.Prefix, opt.SubDir)
 	if len(prefix) > 0 && !strings.HasSuffix(prefix, "/") {
 		prefix += "/"
@@ -194,7 +189,7 @@ func (s *gcsStorage) WalkDir(ctx context.Context, opt *WalkOption, fn func(strin
 	// only need each object's name and size
 	query.SetAttrSelection([]string{"Name", "Size"})
 	iter := s.bucket.Objects(ctx, query)
-	for i := int64(0); i != maxKeys; i++ {
+	for {
 		attrs, err := iter.Next()
 		if err == iterator.Done {
 			break


Test patch:
diff --git a/br/pkg/storage/gcs_test.go b/br/pkg/storage/gcs_test.go
index c3e63d6d410a2..ccf3927497bea 100644
--- a/br/pkg/storage/gcs_test.go
+++ b/br/pkg/storage/gcs_test.go
@@ -4,6 +4,7 @@ package storage
 
 import (
 	"context"
+	"fmt"
 	"io"
 	"os"
 
@@ -95,6 +96,31 @@ func (r *testStorageSuite) TestGCS(c *C) {
 	c.Assert(list, Equals, "keykey1key2")
 	c.Assert(totalSize, Equals, int64(42))
 
+	// test 1003 files
+	totalSize = 0
+	for i := 0; i < 1000; i += 1 {
+		err = stg.WriteFile(ctx, fmt.Sprintf("f%d", i), []byte("data"))
+		c.Assert(err, IsNil)
+	}
+	filesSet := make(map[string]struct{}, 1003)
+	err = stg.WalkDir(ctx, nil, func(name string, size int64) error {
+		filesSet[name] = struct{}{}
+		totalSize += size
+		return nil
+	})
+	c.Assert(err, IsNil)
+	c.Assert(totalSize, Equals, int64(42+4000))
+	_, ok := filesSet["key"]
+	c.Assert(ok, IsTrue)
+	_, ok = filesSet["key1"]
+	c.Assert(ok, IsTrue)
+	_, ok = filesSet["key2"]
+	c.Assert(ok, IsTrue)
+	for i := 0; i < 1000; i += 1 {
+		_, ok = filesSet[fmt.Sprintf("f%d", i)]
+		c.Assert(ok, IsTrue)
+	}
+
 	efr, err := stg.Open(ctx, "key2")
 	c.Assert(err, IsNil)
Repository: traefik/yaegi (Go)

Issue:
Incomplete symbol is not fixed up by importing a package
### The following program `sample.go` triggers an unexpected result

```go
func TestIssueX(t *testing.T) {
	i := interp.New(interp.Options{Env: []string{"foo=bar"}})
	err := i.Use(stdlib.Symbols)
	if err != nil {
		t.Fatal(err)
	}

	_, err = i.Eval(`x := errors.New("")`)
	if err == nil {
		t.Fatal("Expected an error")
	}

	_, err = i.Eval(`import "errors"`)
	if err != nil {
		t.Fatal(err)
	}

	_, err = i.Eval(`x := errors.New("")`)
	if err != nil {
		t.Fatal(err)
	}
}
```


### Expected result

```console
$ go test
=== RUN   TestIssueX
Hello
--- PASS: TestIssueX (0.00s)
PASS
ok      github.com/traefik/yaegi/interp 0.007s
```


### Got

```console
$ go test
=== RUN   TestIssueX
    /home/firelizzard/src/yaegi-fork/interp/interp_eval_test.go:1767: <nil>
--- FAIL: TestIssueX (0.00s)
FAIL
FAIL	github.com/traefik/yaegi/interp	0.007s
```


### Yaegi Version

5665c9a4108e5f878c0d1d8d1e1913eb3c314154

### Additional Notes

_No response_


Discussion:

Patch:
diff --git a/interp/gta.go b/interp/gta.go
index 05b5ac203..d75f0b2e4 100644
--- a/interp/gta.go
+++ b/interp/gta.go
@@ -217,6 +217,12 @@ func (interp *Interpreter) gta(root *node, rpath, importPath, pkgName string) ([
 					if name == "" {
 						name = interp.pkgNames[ipath]
 					}
+
+					// If an incomplete type exists, delete it
+					if sym, exists := sc.sym[name]; exists && sym.kind == typeSym && sym.typ.incomplete {
+						delete(sc.sym, name)
+					}
+
 					// Imports of a same package are all mapped in the same scope, so we cannot just
 					// map them by their names, otherwise we could have collisions from same-name
 					// imports in different source files of the same package. Therefore, we suffix


Test patch:
diff --git a/interp/interp_eval_test.go b/interp/interp_eval_test.go
index d7e756630..7cde405ad 100644
--- a/interp/interp_eval_test.go
+++ b/interp/interp_eval_test.go
@@ -1751,6 +1751,29 @@ func TestRestrictedEnv(t *testing.T) {
 	}
 }
 
+func TestIssue1388(t *testing.T) {
+	i := interp.New(interp.Options{Env: []string{"foo=bar"}})
+	err := i.Use(stdlib.Symbols)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = i.Eval(`x := errors.New("")`)
+	if err == nil {
+		t.Fatal("Expected an error")
+	}
+
+	_, err = i.Eval(`import "errors"`)
+	if err != nil {
+		t.Fatal(err)
+	}
+
+	_, err = i.Eval(`x := errors.New("")`)
+	if err != nil {
+		t.Fatal(err)
+	}
+}
+
 func TestIssue1383(t *testing.T) {
 	const src = `
 			package main