Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Can different custom packages for key and value is possible?

オープン
#8 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
停滞
領域
tooling

調査の方向性

syncmap のコードジェネレーターを見て、現在 types と imports をどのように扱っているかを理解してください。この issue は、keys と values に対して異なる packages の custom types をサポートすることに関するものです。まず map type string の parsing と import 管理を調べてください。custom types に対する既存の tests があるか確認してください。目標は、必要な imports を追加し、circular dependencies を引き起こさずに packages をまたいだ type references を処理するように generator を変更することです。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
Go
スター
257
フォーク
17
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

a8m/syncmap のほかの issue

a8m/syncmap の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。