Skip to content

Commit

Permalink
Re-add maps shortcut to generator
Browse files Browse the repository at this point in the history
Summary:
Essentially revert D53321207, because the original concern is no longer relevant/blocking.
Everyone is on `go1.23.1` now.

Reviewed By: leoleovich

Differential Revision: D63050949

fbshipit-source-id: 9929d93d37ca0425808b9390c65092fabd5ff672
  • Loading branch information
echistyakov authored and facebook-github-bot committed Sep 20, 2024
1 parent 9c9dfcf commit e7f3276
Show file tree
Hide file tree
Showing 81 changed files with 291 additions and 858 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
}}{{> common/header}}

import (
"maps"

{{#program:thrift_imports}}
{{program:go_package_alias}} "{{program:go_import_path}}"
{{/program:thrift_imports}}
Expand All @@ -34,19 +36,10 @@ import (
{{/program:import_metadata_package?}}
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

{{> common/unused_imports_protection}}
// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
{{#program:import_metadata_package?}}
var _ = metadata.GoUnusedProtection__
{{/program:import_metadata_package?}}
Expand Down Expand Up @@ -113,7 +106,7 @@ func GetEnumsMetadata() map[string]*{{program:metadata_qualifier}}ThriftEnum {

// ...now add enum metadatas from recursively included programs.
{{#program:thrift_imports}}
mapsCopy(allEnumsMap, {{program:go_package_alias}}.GetEnumsMetadata())
maps.Copy(allEnumsMap, {{program:go_package_alias}}.GetEnumsMetadata())
{{/program:thrift_imports}}

return allEnumsMap
Expand All @@ -130,7 +123,7 @@ func GetStructsMetadata() map[string]*{{program:metadata_qualifier}}ThriftStruct

// ...now add struct metadatas from recursively included programs.
{{#program:thrift_imports}}
mapsCopy(allStructsMap, {{program:go_package_alias}}.GetStructsMetadata())
maps.Copy(allStructsMap, {{program:go_package_alias}}.GetStructsMetadata())
{{/program:thrift_imports}}

return allStructsMap
Expand All @@ -147,7 +140,7 @@ func GetExceptionsMetadata() map[string]*{{program:metadata_qualifier}}ThriftExc

// ...now add exception metadatas from recursively included programs.
{{#program:thrift_imports}}
mapsCopy(allExceptionsMap, {{program:go_package_alias}}.GetExceptionsMetadata())
maps.Copy(allExceptionsMap, {{program:go_package_alias}}.GetExceptionsMetadata())
{{/program:thrift_imports}}

return allExceptionsMap
Expand All @@ -164,7 +157,7 @@ func GetServicesMetadata() map[string]*{{program:metadata_qualifier}}ThriftServi

// ...now add service metadatas from recursively included programs.
{{#program:thrift_imports}}
mapsCopy(allServicesMap, {{program:go_package_alias}}.GetServicesMetadata())
maps.Copy(allServicesMap, {{program:go_package_alias}}.GetServicesMetadata())
{{/program:thrift_imports}}

return allServicesMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package module

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package cpp

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package hack

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package python

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package rust

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package scope

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package thrift

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package module

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package cpp

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package go_

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package hack

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,15 @@
package scope

import (
"maps"

thrift "github.com/facebook/fbthrift/thrift/lib/go/thrift"
metadata "github.com/facebook/fbthrift/thrift/lib/thrift/metadata"
)

// mapsCopy is a copy of maps.Copy from Go 1.21
// TODO: remove mapsCopy once we can safely upgrade to Go 1.21 without requiring any rollback.
func mapsCopy[M1 ~map[K]V, M2 ~map[K]V, K comparable, V any](dst M1, src M2) {
for k, v := range src {
dst[k] = v
}
}

// (needed to ensure safety because of naive import list construction)
var _ = thrift.ZERO
// TODO: uncomment when can safely upgrade to Go 1.21 without requiring any rollback.
// var _ = maps.Copy[map[int]int, map[int]int]
var _ = maps.Copy[map[int]int, map[int]int]
var _ = metadata.GoUnusedProtection__

// Premade Thrift types
Expand Down
Loading

0 comments on commit e7f3276

Please sign in to comment.