Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Can different custom packages for key and value is possible?

Open
#8 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Domain
tooling

Research direction

Look at the syncmap code generator to understand how it currently handles types and imports. The issue is about supporting custom types from different packages for keys and values. Start by examining the parsing of the map type string and the import management. Check if there are existing tests for custom types. The goal is to modify the generator to add necessary imports and handle type references across packages without causing circular dependencies.

Written by the indexing model from the issue text.

Description

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 ^^

Dominant language
Go
Stars
257
Forks
17
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from a8m/syncmap

All issues in a8m/syncmap

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.