[vscode] 创建erlang gen_serve 文件快捷方式
点击左下角功能按钮,代码片段,新建全局代码片段,然后输入自定义内容就可以
{
"Erlang gen_server": {
"prefix": "genserver",
"body": [
"-module(${1:module_name}).",
"-behaviour(gen_server).",
"",
"%% API",
"-export([start_link/0]).",
"",
"%% gen_server callbacks",
"-export([init/1, handle_call/3, handle_cast/2, handle_info/2,",
" terminate/2, code_change/3]).",
"",
"-record(state, {}).",
"",
"%%%===================================================================",
"%%% API",
"%%%===================================================================",
"",
"start_link() ->",
" gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).",
"",
"%%%===================================================================",
"%%% gen_server callbacks",
"%%%===================================================================",
"",
"init([]) ->",
" {ok, #state{}}.",
"",
"handle_call(Request, _From, State) ->",
" lager:error(\"Unhandled call: ===> ~p\", [Request]),",
" Reply = ok,",
" {reply, Reply, State}.",
"",
"handle_cast(Msg, State) ->",
" lager:error(\"Unhandled cast: ===> ~p\", [Msg]),",
" {noreply, State}.",
"",
"handle_info(Info, State) ->",
" lager:error(\"Unhandled info: ===> ~p\", [Info]),",
" {noreply, State}.",
"",
"terminate(Reason, _State) ->",
" lager:error(\"Server terminated: ===> ~p\", [Reason]),",
" ok.",
"",
"code_change(_OldVsn, State, _Extra) ->",
" {ok, State}."
],
"description": "Template for an Erlang gen_server"
}
}
原文地址:https://blog.csdn.net/fly_vip/article/details/144431004
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!