{"id":19463877,"url":"https://github.com/kasworld/genprotocol","last_synced_at":"2026-05-19T09:08:31.741Z","repository":{"id":57523920,"uuid":"213803106","full_name":"kasworld/genprotocol","owner":"kasworld","description":"generate protocol code ","archived":false,"fork":false,"pushed_at":"2021-03-21T03:38:13.000Z","size":258,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-07-10T07:47:52.026Z","etag":null,"topics":["authorization","golang","golang-sdk","json","metaprogramming","msgpack","network-programming","protocol","webassembly","websocket"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kasworld.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-09T02:34:27.000Z","updated_at":"2023-07-10T07:47:52.027Z","dependencies_parsed_at":"2022-09-15T18:40:26.372Z","dependency_job_id":null,"html_url":"https://github.com/kasworld/genprotocol","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasworld%2Fgenprotocol","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasworld%2Fgenprotocol/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasworld%2Fgenprotocol/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kasworld%2Fgenprotocol/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kasworld","download_url":"https://codeload.github.com/kasworld/genprotocol/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232971700,"owners_count":18604834,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authorization","golang","golang-sdk","json","metaprogramming","msgpack","network-programming","protocol","webassembly","websocket"],"created_at":"2024-11-10T18:12:31.553Z","updated_at":"2026-05-19T09:08:26.714Z","avatar_url":"https://github.com/kasworld.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# genprotocol - protocol 기반 코드 생성\n\n( goguelike 프로젝트를 하면서 만들어진 )\n네트웍 등에서 사용하기 위한 protocol 을 작성하는데 필요한 반복적 이고 기계적인 코드들을 자동으로 생성 해주는 프로그램 입니다. \n\nexample folder 에서 예제를 볼 수 있습니다. \n\n작성 이유는 하나의 프로젝트에서 여러종의 protocol 을 사용할 일이 생겨서 \n반복된 코드를 작성하다 보니 만들게 되었습니다. \n\ngoguelike 를 예로 들면 \n\ngame client - tower server \n\ntower server - ground server \n\n의 2종의 protocol이 필요하고 사실상 비슷한데 조금 다른 코드들이 서로 구별 되어 쓰입니다. \n\n\n\n## 사용 법 \n위 와 같은 경우 \n\ngenprotocol -ver=1.2 -prefix=c2t -basedir=. \n\ngenprotocol -ver=1.0 -prefix=t2g -basedir=. \n\n과 같은 형태로 실행합니다. \n\n자동 생성된 파일은 모두 _gen.go 로 끝나는 이름을 가집니다.\n \n\n### 인자 설명 \n\nver : protocol의 version ( protocol 마다 버전이 다를 수 있습니다. )\n\nprefix : 각 protocol을 구별하기 위한 prefix \n\nbasedir : protocol code가 생성될 기본 폴더, 여기서 prefix_*.enum 을 읽습니다. \n\n## example/rundriver 디렉토리 \n\njson을 serializer로 사용하는 \ntcp server/client, \nwebsocket server/client \n예제 입니다. \n\n## genprotocol에서 읽어 들이는 파일들 \n\n\t인자로준 basedir 폴더내에서 찾습니다. \n\t\n\t각 라인의 첫 단어가 enum 이고 space 로 분리된 뒷 부분은 생성된 코드의 comment가 된다. \n\t# 으로 시작하는 라인은 무시(comment취급)\n\tprefix_command.enum : request/response packet 용 command id 목록 \n\tprefix_noti.enum    : notification packet 용 noti id 목록 \n\tprefix_error.enum   : error code 목록 \n\n\n## 생성되는 go package (디렉토리)\n\nprefix 는 genprotocol 에 prefix 인자로 준 값 \n\n생성이 끝난 코드들은 import code가 제대로 되어 있지 않으니 \ngoimports 등으로 정리 해주어야 합니다. \n\n-verbose 인자를 주고 실행하면 goimports 를 해야할 파일 목록을 찍어 줍니다. \n\t\n\texample.sh 를 실행한 결과 \n\tgoimports -w example/c2s_version/version_gen.go\n\tgoimports -w example/c2s_idcmd/command_gen.go\n\tgoimports -w example/c2s_idnoti/noti_gen.go\n\tgoimports -w example/c2s_error/error_gen.go\n\tgoimports -w example/c2s_const/const_gen.go\n\tgoimports -w example/c2s_packet/packet_gen.go\n\tgoimports -w example/c2s_obj/objtemplate_gen.go\n\tgoimports -w example/c2s_msgp/serialize_gen.go\n\tgoimports -w example/c2s_json/serialize_gen.go\n\tgoimports -w example/c2s_handlersp/fnobjtemplate_gen.go\n\tgoimports -w example/c2s_handlersp/fnbytestemplate_gen.go\n\tgoimports -w example/c2s_handlenoti/fnobjtemplate_gen.go\n\tgoimports -w example/c2s_handlenoti/fnbytestemplate_gen.go\n\tgoimports -w example/c2s_handlereq/fnobjtemplate_gen.go\n\tgoimports -w example/c2s_handlereq/fnbytestemplate_gen.go\n\tgoimports -w example/c2s_serveconnbyte/serveconnbyte_gen.go\n\tgoimports -w example/c2s_connbytemanager/connbytemanager_gen.go\n\tgoimports -w example/c2s_conntcp/conntcp_gen.go\n\tgoimports -w example/c2s_connwasm/connwasm_gen.go\n\tgoimports -w example/c2s_connwsgorilla/connwsgorilla_gen.go\n\tgoimports -w example/c2s_loopwsgorilla/loopwsgorilla_gen.go\n\tgoimports -w example/c2s_looptcp/looptcp_gen.go\n\tgoimports -w example/c2s_pid2rspfn/pid2rspfn_gen.go\n\tgoimports -w example/c2s_statnoti/statnoti_gen.go\n\tgoimports -w example/c2s_statcallapi/statcallapi_gen.go\n\tgoimports -w example/c2s_statserveapi/statserveapi_gen.go\n\tgoimports -w example/c2s_statapierror/statapierror_gen.go\n\tgoimports -w example/c2s_authorize/authorize_gen.go\n\n\n\t인자로 -statstype=elementtype 이 주어진 경우 추가로 생성\n\tgoimports -w example/c2s_error_stats/c2s_error_stats_gen.go\n\tgoimports -w example/c2s_idcmd_stats/c2s_idcmd_stats_gen.go\n\tgoimports -w example/c2s_idnoti_stats/c2s_idnoti_stats_gen.go\n\n\n\nprefix_obj : protocol struct 들 (packet body)\n\n\t생성하는 파일 \n\tobjtemplate_gen.go : 예제 파일 - 참고해서 \"_gen\"이 없는 파일을 만들것 \n\nprefix_handlereq :   commandid -\u003e api function map, 과 예제 api function들 \n\n\t생성하는 파일 \n\tfnbytestemplate_gen : packetbody 가 []byte 인 형태로 api로 demux, unmarshal을 api 쪽에서 해야 함 \n\tfntemplate_gen  : packetbody 가 interface{} 인 형태로 api로 demux, unmarshal 후에 demux map을 호출 해야 함. \n\nprefix_version : protocol version 정보 \n\n\t생성하는 파일 \n\tversion_gen.go\n\nprefix_error : protocol error code list, errorcode type은 error를 구현하고 있다.\n\n\t생성하는 파일 \n\terror_gen.go \n\nprefix_idcmd : protocol command (request,response) list \n\n\t생성하는 파일 \n\tcommand_gen.go\n\nprefix_idnoti : protocol notification list \n\n\t생성하는 파일 \n\tnoti_gen.go\n\nprefix_const : 각종 상수들 , 설정의 변경이 가능하도록 모아둠. \n\n\t생성하는 파일 \n\tconst_gen.go : 복사해서 _gen 이 없는 파일을 만들고 comment를 풀어 사용할것.\n\nprefix_packet : protocol packet( header + body )\n\n\t생성하는 파일 \n\tpacket_gen.go\n\nprefix_msgp : messagepack marshal/unmarshal code (https://github.com/tinylib/msgp)\n\n\t생성하는 파일 \n\tserialize_gen.go\n \nprefix_json : json marshal/unmarshal code \n\n\t생성하는 파일 \n\tserialize_gen.go\n\nprefix_gob : gob marshal/unmarshal code \n\n\t생성하는 파일 \n\tserialize_gen.go\n\n\nprefix_loopwsgorilla : go server/client용 gorilla websocket Send/Recv loop ([gorilla](http://www.gorillatoolkit.org/pkg/websocket)) \n\n\t생성하는 파일 \n\tloopwsgorilla_gen.go\n\nprefix_looptcp : go server/client용 TCP Send/Recv loop\n\n\t생성하는 파일 \n\tlooptcp_gen.go\n\nprefix_serveconnbyte : server 용 connection api 처리 (tcp, websocket) packet body []byte 형태 \n\n\t생성하는 파일 \n\tserveconnbyte_gen.go\n\nprefix_connbytemanager : server 용 connection manager, server에 연결된 connection(prefix_serveconnbyte) 을 관리한다. \n\n\t생성하는 파일 \n\tconnbytemanager_gen.go\n\nprefix_connwasm : websocket wasm client 용 connection\n\n\t생성하는 파일 \n\tconnwasm_gen.go\n\nprefix_connwsgorilla : gorilla websocket  client 용 connection \n\n\t생성하는 파일 \n\tconnwsgorilla_gen.go\n\nprefix_conntcp : tcp client 용 connection \n\n\t생성하는 파일 \n\tconntcp_gen.go\n\nprefix_handlersp : response 를 받아서 처리 \n\n\t생성하는 파일 \n\trecvrspobjfnmap_gen.go   : 받은 response 처리 \n\nprefix_handlenoti : notification을 받아서 처리 \n\n\t생성하는 파일 \n\trecvnotiobjfnmap_gen.go  : 받은 notification 처리 \n\nprefix_pid2rspfn : callback 형태로 request/response를 처리하기위한 lib(client example참조)\n\n\t생성하는 파일 \n\tpid2rspfn_gen.go      \n\nprefix_statnoti : notification protocol 통계 \n\n\t생성하는 파일 \n\tstatnoti_gen.go\t\n\nprefix_statcallapi : client api call 통계 \n\n\t생성하는 파일 \n\tstatcallapi_gen.go\t\n\nprefix_statserveapi : server api 처리 통계 \n\n\t생성하는 파일 \n\tstatserveapi_gen.go\t\n\nprefix_statapierror : api 결과 error 통계 \n\n\t생성하는 파일 \n\tstatapierror_gen.go\t\n\nprefix_authorize : client api call의 권한 관리 (commandid 기준)\n\n\t생성하는 파일 \n\tauthorize_gen.go\t\n\n## 인자로 -statstype=elementtype 이 주어진 경우 추가로 생성하는 패키지 \n\nprefix_error_stats : elementtype을 구성요소로한 simple errorcode 통계 (genenum에서 가져옴)\n\n\t생성하는 파일 \n\tprefix_error_stats_gen.go\t\n\nprefix_idcmd_stats : elementtype을 구성요소로한 simple commandid 통계 (genenum에서 가져옴)\n\n\t생성하는 파일 \n\tprefix_idcmd_stats_gen.go\t\n\nprefix_idnoti_stats : elementtype을 구성요소로한 simple notiid 통계 (genenum에서 가져옴)\n\n\t생성하는 파일 \n\tprefix_idnoti_stats_gen.go\t\n\n\n## websocket 을 사용하려면 \n\n\tgo get github.com/gorilla/websocket\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasworld%2Fgenprotocol","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkasworld%2Fgenprotocol","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkasworld%2Fgenprotocol/lists"}