sskycn
V2EX  ›  OpenAI

重新启用 gskctl, 一个基于 dsl 的代码生成工具

  •  
  •   sskycn ·
    afxcn · 4h 23m ago · 152 views

    为了确保写出来的代码一定是高效稳定的,我重新启用 gskctl 了。

    用 AI 写模板,用它生成代码,好像还不错。

    type UserRepository interface {
    	// @QueryRow("select * from User where Id = :id")
    	GetUser(ctx context.Context, id uint64) (User, error)
    
    	// @Query("select U.Id, U.Name, T.Name as TeamName from User as U left join Team as T where U.Active is true and (U.Name like :name or T.Name is null) order by U.Name limit :limit offset :offset")
    	ListUsers(ctx context.Context, name string, limit int, offset int) ([]ListUsersRow, error)
    
    	// @Create("insert into User (Id, Name, Active) values (:id, :name, true) on conflict (Id) do update set Name = excluded.Name returning *")
    	UpsertUser(ctx context.Context, id uint64, name string) (User, error)
    
    	// @Update("update User set Name = coalesce(:name, Name) where Id = :id returning Id, Name")
    	RenameUser(ctx context.Context, name string, id uint64) ([]RenameUserRow, error)
    
    	// @Delete("delete from User where Id = :id")
    	DeleteUser(ctx context.Context, id uint64) (sql.Result, error)
    }
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   935 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 20ms · UTC 21:20 · PVG 05:20 · LAX 14:20 · JFK 17:20
    ♥ Do have faith in what you're doing.