[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"
    }
}
相关推荐
2501_9159214312 小时前
iOS开发环境搭建详解 Xcode 配置与快蝎轻量级工具选择
ide·vscode·macos·ios·个人开发·xcode·敏捷流程
wardenlzr15 小时前
VSCode 运行 Live Server 提示「Windows 找不到文件 Chrome」问题全解析
chrome·windows·vscode
程序员more15 小时前
我用 AI,20 分钟做了一个 VSCode 股票摸鱼插件
人工智能·vscode
减瓦17 小时前
告别Postman——用VSCode优雅地发起Http请求
vscode·http·postman
csdn2015_20 小时前
vscode从gitlab拉项目到本地
vscode·gitlab
Patrick_Wilson2 天前
为什么让程序主动崩溃反而更可靠?聊聊 supervisor 与 let it crash
后端·erlang·elixir
shmily麻瓜小菜鸡2 天前
浏览器在请求外部图片(403 Forbidden)问题
vue.js·vscode·echarts·angular.js
Yolanda_20223 天前
在vscode终端中可使用pip,但是cmd终端中找不到命令 pip问题的解决
vscode·python·conda·pip
π同学3 天前
ESP-IDF+vscode开发ESP32 联网篇第一讲——WIFI扫描
vscode·esp32c6·wifi scan
Irene19914 天前
怎么设置 PyCharm 使用 VSCode 的快捷键,推荐保留的原生快捷键(特色功能不建议覆盖,否则丧失效率优势)Ctrl+Alt+L:代码格式化
vscode·pycharm·快捷键