Skip to content

Instantly share code, notes, and snippets.

@kevsmith
Created September 12, 2011 14:14
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save kevsmith/1211350 to your computer and use it in GitHub Desktop.
Save kevsmith/1211350 to your computer and use it in GitHub Desktop.
Example of gen_server template output
%% -*- erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et
%% @author Kevin Smith <kevin@opscode.com>
%% @copyright 2011 Opscode, Inc.
-module(example).
-behaviour(gen_server).
-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, {}).
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
init([]) ->
{ok, #state{}}.
handle_call(_Request, _From, State) ->
{reply, ignored, State}.
handle_cast(_Msg, State) ->
{noreply, State}.
handle_info(_Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
ok.
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
%% Internal functions
@Elzor
Copy link

Elzor commented Jul 31, 2013

good template

@kingwang98
Copy link

It does not work for me, why? No name and attributes replaced. Something might need to be updated?

|-- global
|-- template_vars
-- templates |-- README.md |-- common | |-- Makefile | |-- app.src | |-- gitignore | |-- rebar.config |-- test.erl
|-- gen_server
| -- gen_server.erl |-- gen_server.template |-- library |-- module.erl
|-- library.template
|-- mod.template
|-- supapp
| |-- app.erl
| -- supervisor.erl -- supapp.template

%% -- erlang-indent-level: 4;indent-tabs-mode: nil --
%% ex: ts=4 sw=4 et
%% @author {{author}} <{{author_email}}>
%% @copyright {{copyright_year}} {{copyright_holder}}

-module(esi_srv).

-behaviour(gen_server).

-export([start_link/0]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment