1
0
mirror of https://github.com/go-kratos/kratos.git synced 2024-12-26 20:54:38 +02:00

fix(contrib/polaris): incorrect conversion between integer types (#3300)

* fix(contrib/polaris): convert string to int32

* fix
This commit is contained in:
jessetang 2024-04-27 19:37:55 +08:00 committed by GitHub
parent b3b2a3474a
commit 45603e3ab9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -114,7 +114,7 @@ func buildPolarisInstance(namespace string, nodes []selector.Node) *pb.ServiceIn
if err != nil {
return nil
}
portInt, err := strconv.Atoi(port)
portUint64, err := strconv.ParseUint(port, 10, 32) //nolint:gomnd
if err != nil {
return nil
}
@ -123,7 +123,7 @@ func buildPolarisInstance(namespace string, nodes []selector.Node) *pb.ServiceIn
Service: wrapperspb.String(node.ServiceName()),
Namespace: wrapperspb.String(namespace),
Host: wrapperspb.String(host),
Port: wrapperspb.UInt32(uint32(portInt)),
Port: wrapperspb.UInt32(uint32(portUint64)),
Protocol: wrapperspb.String(node.Scheme()),
Version: wrapperspb.String(node.Version()),
Weight: wrapperspb.UInt32(uint32(*node.InitialWeight())),