Token导航 LogoToken导航TokenDH.com
前端设计需要联网github未标认证来源可访问许可证需确认审计通过

go-mapper去映射器

Agent Skill

go-mapper 用于处理 GitHub 仓库、Issue、Pull Request 和代码协作信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

269

周安装

11

GitHub Stars

公开资料未说明

下载量

87
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:go-mapper(去映射器)
来源仓库:https://github.com/cristiano-pacheco/ai-tools
仓库路径:skills/go-mapper
安装命令:
npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-mapper
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/cristiano-pacheco/ai-tools --skill go-mapper

简介

用于处理 GitHub 仓库、Issue 和 Pull Request 协作信息。

  • 适合在代码变更管理和协作事项整理等场景中使用。
  • 可帮助 Agent 围绕仓库状态进行信息梳理和下一步操作建议。
  • 使用时需区分只读查询与写入操作的安全边界。go-mapper 属于前端设计类 Skill,可作为该场景下的辅助能力补充。
  • 安装前应确认 token 权限和维护状态,避免触发未授权操作。

SKILL.md

Go Mapper

Generate pure mapper functions for GO modular architecture.

When to Use

  • Map HTTP request DTOs to use case inputs
  • Map persistence models to HTTP response DTOs
  • Map between any two struct representations across layers
  • Convert a slice of structs to a slice of another struct
  • Any struct-to-struct transformation that lives in a module

Location

All mapper files live in internal/modules/<module>/mapper/.

One file per domain concept: <name>_mapper.go (e.g., user_mapper.go).

Function Signature Pattern

Every mapper function follows the To prefix convention. It accepts one or more inputs and returns exactly one output, optionally with an error.

func ToXxx(input InputType) OutputType
func ToXxx(input InputType) (OutputType, error)
func ToXxx(a TypeA, b TypeB) OutputType

Single output only. Error is the only allowed second return value.

File Structure

  1. Package declaration and imports
  2. Public mapper functions
  3. Private helper functions (shared logic between public functions)

Examples

Basic mapper

package mapper

import (
	"github.com/cristiano-pacheco/pingo/internal/modules/user/dto"
	"github.com/cristiano-pacheco/pingo/internal/modules/user/model"
	"github.com/cristiano-pacheco/pingo/internal/modules/user/usecase"
)

func ToCreateUserInput(req dto.CreateUserRequest) usecase.CreateUserInput {
	return usecase.CreateUserInput{
		Name:  req.Name,
		Email: req.Email,
	}
}

func ToUserResponse(u model.UserModel) dto.UserResponse {
	return dto.UserResponse{
		ID:        u.ID,
		Name:      u.Name,
		Email:     u.Email,
		CreatedAt: u.CreatedAt,
	}
}

func ToUserListResponse(models []model.UserModel) []dto.UserResponse {
	responses := make([]dto.UserResponse, len(models))
	for i, u := range models {
		responses[i] = ToUserResponse(u)
	}
	return responses
}

Mapper with multiple inputs

package mapper

import (
	"github.com/cristiano-pacheco/pingo/internal/modules/order/dto"
	"github.com/cristiano-pacheco/pingo/internal/modules/order/model"
)

func ToOrderResponse(order model.OrderModel, items []model.OrderItemModel) dto.OrderResponse {
	return dto.OrderResponse{
		ID:    order.ID,
		Total: order.Total,
		Items: toOrderItemResponses(items),
	}
}

func toOrderItemResponses(items []model.OrderItemModel) []dto.OrderItemResponse {
	responses := make([]dto.OrderItemResponse, len(items))
	for i, item := range items {
		responses[i] = dto.OrderItemResponse{
			ID:       item.ID,
			Name:     item.ProductName,
			Quantity: item.Quantity,
			Price:    item.Price,
		}
	}
	return responses
}

Mapper with error return

Use when transformation can fail (e.g., parsing, validation during mapping).

package mapper

import (
	"github.com/cristiano-pacheco/pingo/internal/modules/product/dto"
	"github.com/cristiano-pacheco/pingo/internal/modules/product/errs"
	"github.com/cristiano-pacheco/pingo/internal/modules/product/model"
)

func ToProductModel(req dto.CreateProductRequest) (model.ProductModel, error) {
	price, err := parsePrice(req.Price)
	if err != nil {
		return model.ProductModel{}, errs.ErrInvalidPrice
	}
	return model.ProductModel{
		Name:  req.Name,
		Price: price,
	}, nil
}

Slice mapper pattern

When mapping a single item, add a corresponding list function if the type appears in collections.

func ToArticleResponse(a model.ArticleModel) dto.ArticleResponse {
	return dto.ArticleResponse{
		ID:     a.ID,
		Title:  a.Title,
		Author: toAuthorResponse(a),
	}
}

func ToArticleListResponse(models []model.ArticleModel) []dto.ArticleResponse {
	responses := make([]dto.ArticleResponse, len(models))
	for i, a := range models {
		responses[i] = ToArticleResponse(a)
	}
	return responses
}

func toAuthorResponse(a model.ArticleModel) dto.AuthorResponse {
	return dto.AuthorResponse{
		ID:   a.AuthorID,
		Name: a.AuthorName,
	}
}

Naming

  • File: <name>_mapper.go in mapper/ package
  • Public functions: ToXxx — where Xxx is the output type name (e.g., ToUserResponse, ToCreateUserInput)
  • Private helpers: toXxx — lowercase prefix for shared sub-mapping logic
  • Slice variants: ToXxxList or ToXxxListResponse

Rules

  1. Functions only — no structs, no interfaces, no constructors, no port files
  2. To prefix — every public function starts with To
  3. Single output — one return value, or one return value + error
  4. No context.Context — mappers are pure transformations, no I/O
  5. No side effects — no logging, no database calls, no external dependencies
  6. Private helpers — extract shared sub-mapping logic into private functions
  7. No comments on functions — function names are self-documenting via the To convention
  8. Slice helpers — add a list variant when the mapped type appears in collections
  9. Error return only when transformation can fail — prefer no-error signatures; use error only for parsing or conversion failures

Workflow

  1. Create mapper file in mapper/<name>_mapper.go
  2. Run make lint to verify code quality
  3. Run make nilaway for static analysis

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

38.82%
按下载量换算34

Claude

29.07%
按下载量换算25

Cursor

19.01%
按下载量换算17

Gemini CLI

10.01%
按下载量换算9

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills