a8m / a8m/syncmap

Can different custom packages for key and value is possible?

Offen
#8 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Go
Sterne
256
Forks
17
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Hi @a8m ,

Currently using a basic
```
syncmap -name UserChannelsMap -pkg xmap -o ./types/xmap/user_channels_map.go "map[string]string"
```
will work.

If I want to use a custom type:
```
syncmap -name UserChannelsMap -pkg xmap -o ./types/xmap/user_channels_map.go "map[string]*UserChannelList"
```
I need to make sure `UserChannelList` is in the same package than the one exported for the file (here `xmap`). I could arrange myself to do so, but it brings some complexity.

Last case, I want to use like an "enum" for the keys, in my case it's defined in my own `constant` package, how could I deal with this? From what I understand it's not possible, the `syncmap` would have to manage some add of imports, no?
```
syncmap -name UserChannelsMap -pkg xmap -o ./types/xmap/user_channels_map.go "map[constant.NameID]*UserChannelList"
```

Maybe I missed something 🤔

Thank you,

EDIT: a workaround could be that aside my exported file (having package `xmap`) I could declare type aliases for both the key and the value types, like:
```
import ...

type NameID = constant.NameID
type UserChannelList = entity.UserChannelList
```

EDIT2: in all cases, I should make sure it won't bring circular loop if the XXXMap was needed in one of those packages ^^

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.