Skip to content

Tags

Tags

v2.10.4

Toggle v2.10.4's commit message
Release v2.10.4

contrib/trace/otlphttp/v2.10.4

Toggle contrib/trace/otlphttp/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/trace/otlpgrpc/v2.10.4

Toggle contrib/trace/otlpgrpc/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/sdk/httpclient/v2.10.4

Toggle contrib/sdk/httpclient/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/rpc/grpcx/v2.10.4

Toggle contrib/rpc/grpcx/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/registry/zookeeper/v2.10.4

Toggle contrib/registry/zookeeper/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/registry/polaris/v2.10.4

Toggle contrib/registry/polaris/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/registry/nacos/v2.10.4

Toggle contrib/registry/nacos/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/registry/file/v2.10.4

Toggle contrib/registry/file/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.

contrib/registry/etcd/v2.10.4

Toggle contrib/registry/etcd/v2.10.4's commit message

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
fix(cmd/gf): avoid duplicate imports when ensuring an existing path (#…

…4945)

Follow-up to #4929.

## What

`EnsureImports` now matches imports by their path before calling
`astutil.AddNamedImport`.

`astutil.AddNamedImport` matches on `(name, path)`, and an unnamed
import has an empty name. A controller generated by an older gf version
imports the api package without an alias:

```go
import "project/api/hello/v1"
```

When `gf gen pb` regenerates it with a new RPC method, `EnsureImports`
passes `{Name: "v1", Path: ...}`, does not recognize the existing
unnamed import, and adds a second import of the same path:

```go
import (
	"project/api/hello/v1"
	v1 "project/api/hello/v1"
)
```

The generated controller no longer compiles.

## How

- Check the existing paths first; an already imported path is never
imported again.
- An existing unnamed import satisfies the spec, which covers
controllers generated by older versions.
- Blank/dot imports and explicit aliases that differ from the required
one return an error instead of writing duplicate imports.

## Compatibility

Freshly generated files are unchanged. Existing controllers no longer
get a duplicate import. Conflicting existing imports now fail with a
clear error instead of producing code that does not compile. This is an
internal utility only; no public API change.

## Tests

- `Test_EnsureImports_ExistingPath`: unnamed existing import + requested
alias, same alias, alias conflict, blank conflict, redundant alias.
- `TestGenPb_ControllerImports`: generate a controller in the standard
`hello/v1` layout, strip the api alias to simulate an older controller,
regenerate, and assert the api path appears once.
- `go test ./internal/utility/utils/ ./internal/cmd/gendao/` and
`TestGenPb_ControllerImports` pass.