[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"
    }
}
相关推荐
BestOrNothing_20155 小时前
Ubuntu 22.04 下调整 VS Code 界面及字体教程
linux·vscode·ubuntu22.04·界面调整
计算机安禾5 小时前
【C语言程序设计】第39篇:预处理器与宏定义
c语言·开发语言·c++·vscode·算法·visual studio code·visual studio
monsion21 小时前
OpenCode 学习指南
人工智能·vscode·架构
非鱼䲆鱻䲜1 天前
vscode开发stm32添加新的头文件路径和包含源文件
ide·vscode·stm32·cmake·包含头文件·包含源文件
liurunlin8881 天前
Go环境搭建(vscode调试)
开发语言·vscode·golang
Willliam_william1 天前
QEMU学习之路(11)— 使用VSCode调试qemu-system-riscv64
ide·vscode·学习
TroubleMakerQi1 天前
[虚拟机环境配置]07_Ubuntu中安装vscode教程
linux·人工智能·vscode·ubuntu
zhensherlock1 天前
Protocol Launcher 系列:Trae AI 编辑器的深度集成
javascript·人工智能·vscode·ai·typescript·编辑器·ai编程
不解不惑1 天前
MacOS系统ssh和ftp,使用vscode实现
vscode·macos·ssh
π同学2 天前
ESP-IDF+vscode开发ESP32第二讲——console
vscode·esp32·console