Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

This article is a Private article. Only a writer and users who know the URL can access it.
Please change open range to public in publish setting if you want to share this article with other users.

More than 1 year has passed since last update.

go tool

Last updated at Posted at 2023-07-02

create struct from ddl

paste on A1 (google spread sheet)

.csv
テーブル名	t_mst_usr		struct	constructor	for work
物理名	論理名	Goの型	="type "&REPLACE(REGEXREPLACE(PROPER(B1),"_",""),1,1,PROPER(LEFT(B1,1)))&" struct {"	="func New"&REPLACE(REGEXREPLACE(PROPER(B1),"_",""),1,1,PROPER(LEFT(B1,1)))&"("&TEXTJOIN(",",true,F3:F8)&") *"&REPLACE(REGEXREPLACE(PROPER(B1),"_",""),1,1,PROPER(LEFT(B1,1)))&" {"	-
id	ID	int	=IF(A3<>"",REPLACE(REGEXREPLACE(PROPER(A3),"_",""),1,1,PROPER(LEFT(A3,1)))&" "&C3&" // "&B3,"}")	="u := new("&REPLACE(REGEXREPLACE(PROPER(B1),"_",""),1,1,PROPER(LEFT(B1,1)))&")"	=REPLACE(REGEXREPLACE(PROPER(A3),"_",""),1,1,LOWER(LEFT(A3,1)))&" "&C3
name	名前	string	=IF(A4<>"",REPLACE(REGEXREPLACE(PROPER(A4),"_",""),1,1,PROPER(LEFT(A4,1)))&" "&C4&" // "&B4,"}")	=IF(A3<>"","u."&REPLACE(REGEXREPLACE(PROPER(A3),"_",""),1,1,PROPER(LEFT(A3,1)))&" = "&REPLACE(REGEXREPLACE(PROPER(A3),"_",""),1,1,LOWER(LEFT(A3,1))),IF(E3="return u","}","return u"))	=REPLACE(REGEXREPLACE(PROPER(A4),"_",""),1,1,LOWER(LEFT(A4,1)))&" "&C4
usr_login_id	ログインID	string	=IF(A5<>"",REPLACE(REGEXREPLACE(PROPER(A5),"_",""),1,1,PROPER(LEFT(A5,1)))&" "&C5&" // "&B5,"}")	=IF(A4<>"","u."&REPLACE(REGEXREPLACE(PROPER(A4),"_",""),1,1,PROPER(LEFT(A4,1)))&" = "&REPLACE(REGEXREPLACE(PROPER(A4),"_",""),1,1,LOWER(LEFT(A4,1))),IF(E4="return u","}","return u"))	=REPLACE(REGEXREPLACE(PROPER(A5),"_",""),1,1,LOWER(LEFT(A5,1)))&" "&C5
usr_pass_word	パスワード	string	=IF(A6<>"",REPLACE(REGEXREPLACE(PROPER(A6),"_",""),1,1,PROPER(LEFT(A6,1)))&" "&C6&" // "&B6,"}")	=IF(A5<>"","u."&REPLACE(REGEXREPLACE(PROPER(A5),"_",""),1,1,PROPER(LEFT(A5,1)))&" = "&REPLACE(REGEXREPLACE(PROPER(A5),"_",""),1,1,LOWER(LEFT(A5,1))),IF(E5="return u","}","return u"))	=REPLACE(REGEXREPLACE(PROPER(A6),"_",""),1,1,LOWER(LEFT(A6,1)))&" "&C6
			=IF(A7<>"",REPLACE(REGEXREPLACE(PROPER(A7),"_",""),1,1,PROPER(LEFT(A7,1)))&" "&C7&" // "&B7,"}")	=IF(A6<>"","u."&REPLACE(REGEXREPLACE(PROPER(A6),"_",""),1,1,PROPER(LEFT(A6,1)))&" = "&REPLACE(REGEXREPLACE(PROPER(A6),"_",""),1,1,LOWER(LEFT(A6,1))),IF(E6="return u","}","return u"))	 =REPLACE(REGEXREPLACE(PROPER(A7),"_",""),1,1,LOWER(LEFT(A7,1)))&" "&C7
				=IF(A7<>"","u."&REPLACE(REGEXREPLACE(PROPER(A7),"_",""),1,1,PROPER(LEFT(A7,1)))&" = "&REPLACE(REGEXREPLACE(PROPER(A7),"_",""),1,1,LOWER(LEFT(A7,1))),IF(E7="return u","}","return u"))	 =REPLACE(REGEXREPLACE(PROPER(A8),"_",""),1,1,LOWER(LEFT(A8,1)))&" "&C8
				=IF(A8<>"","u."&REPLACE(REGEXREPLACE(PROPER(A8),"_",""),1,1,PROPER(LEFT(A8,1)))&" = "&REPLACE(REGEXREPLACE(PROPER(A8),"_",""),1,1,LOWER(LEFT(A8,1))),IF(E8="return u","}","return u"))	 =REPLACE(REGEXREPLACE(PROPER(A9),"_",""),1,1,LOWER(LEFT(A9,1)))&" "&C9

result
Green Area: header + values from ddl
Orange Area: struct
Blue Area: constructor
deep blue area:work (have to paste)
image.png

maybe occure this #ERROR! at first, but
image.png

Enter 2 times
image.png

then fixed.
image.png

initiation

# initiate
go mod init PROJECTNAME

# libs (Gin, CORS, Postgres)
go install github.com/gin-gonic/gin@latest
go get github.com/gin-contrib/cors
go get github.com/lib/pq

# run
go run .

# run detach
go run . &

0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?