[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"
    }
}
相关推荐
F1FJJ4 小时前
Shield CLI PostgreSQL 插件现已上架 VS Code 扩展市场
网络·vscode·网络协议·postgresql·开源软件
golang学习记6 小时前
VS Code 1.113 发布:Agent 与 Chat 体验全面升级!
vscode·microsoft
Sarapines Programmer8 小时前
【VSCode插件】VSCode 插件 Roo Code 简明指南
ide·vscode·编辑器
monsion9 小时前
Code Agent 不是编程工具:它是今天最接近通用 Agent 的现成形态
人工智能·vscode·个人开发
千里马学框架10 小时前
aospc/c++的native 模块VScode和Clion
android·开发语言·c++·vscode·安卓framework开发·clion·车载开发
原来是猿10 小时前
VSCode常见快捷键大全
ide·vscode·编辑器
承渊政道11 小时前
【优选算法】(实战掌握分治思想的使用方法)
数据结构·c++·笔记·vscode·学习·算法·leetcode
shughui11 小时前
Cursor下载安装以及和VSCode的区别(附安装包)
ide·vscode·ai·编辑器·cursor
FateRing1 天前
vscode插件fail to fecth
ide·vscode·编辑器
螺丝钉code1 天前
迁移到 Openrouter 后 Claude Code Vscode 插件出现了一些奇怪的问题
ide·vscode·编辑器