"use strict";(self.webpackChunkgoffee_site=self.webpackChunkgoffee_site||[]).push([[7924],{8578:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>a,contentTitle:()=>i,default:()=>h,frontMatter:()=>s,metadata:()=>c,toc:()=>l});var o=n(4848),r=n(8453);const s={title:"Getting Started"},i=void 0,c={id:"getting-started",title:"Getting Started",description:"To create a new Goffee project you need to install the command goffee first. It is the cli tool.",source:"@site/docs/getting-started.md",sourceDirName:".",slug:"/getting-started",permalink:"/goffee/docs/getting-started",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{title:"Getting Started"},sidebar:"docsSidebar",previous:{title:"Installation",permalink:"/goffee/docs/installation"},next:{title:"Environment Variables",permalink:"/goffee/docs/environment-variables"}},a={},l=[{value:"Installing the CLI tool [goffee]",id:"installing-the-cli-tool-goffee",level:4},{value:"Create a new project:",id:"create-a-new-project",level:4},{value:"Add a route",id:"add-a-route",level:4}];function d(e){const t={a:"a",code:"code",h4:"h4",p:"p",pre:"pre",...(0,r.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(t.p,{children:["To create a new Goffee project you need to install the command ",(0,o.jsx)(t.code,{children:"goffee"})," first. It is the ",(0,o.jsx)(t.code,{children:"cli tool"}),"."]}),"\n",(0,o.jsx)(t.h4,{id:"installing-the-cli-tool-goffee",children:"Installing the CLI tool [goffee]"}),"\n",(0,o.jsxs)(t.p,{children:["To install the ",(0,o.jsx)(t.code,{children:"goffee"})," globally open up your terminal and run the following command:"]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-bash",children:"go install git.smarteching.com/goffee/goffee@latest\n"})}),"\n",(0,o.jsxs)(t.p,{children:["Detailed instructions in ",(0,o.jsx)(t.a,{href:"https://docu.smarteching.com/goffee/docs/installation",children:"installation"})]}),"\n",(0,o.jsx)(t.h4,{id:"create-a-new-project",children:"Create a new project:"}),"\n",(0,o.jsx)(t.p,{children:"To create a new project run the following command"}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-bash",children:"goffee new myapp git.smarteching.com/goffee/myapp\n"})}),"\n",(0,o.jsxs)(t.p,{children:["Where:\n",(0,o.jsx)(t.code,{children:"myapp"})," is the name of your project.\n",(0,o.jsx)(t.code,{children:" git.smarteching.com/goffee/myapp"})," is the remote repository that will host the project"]}),"\n",(0,o.jsx)(t.h4,{id:"add-a-route",children:"Add a route"}),"\n",(0,o.jsxs)(t.p,{children:["Let's create a route that returns ",(0,o.jsx)(t.code,{children:"hello world"}),"\nOpen up the file ",(0,o.jsx)(t.code,{children:"routes.go"})," in the root of your project and add to it the code below:"]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-go",metastring:'"file: routes.go"',children:'controller.Get("/greeting", func(c *core.Context) *core.Response {\n\tJsonString := `{"message": "hello world"}`\n\n\treturn c.Response.Json(JsonString)\n})\n'})}),"\n",(0,o.jsxs)(t.p,{children:["Next, in your terminal navigate to the project dir and run the following command to start the ",(0,o.jsx)(t.code,{children:"live reloading"}),":"]}),"\n",(0,o.jsx)(t.pre,{children:(0,o.jsx)(t.code,{className:"language-go",children:"goffee run:dev\n"})}),"\n",(0,o.jsxs)(t.p,{children:["Finally, open up your browser and navigate to ",(0,o.jsx)(t.code,{children:"http://localhost:8080/greeting"})]}),"\n",(0,o.jsxs)(t.p,{children:["To learn more check the ",(0,o.jsx)(t.a,{href:"https://docu.smarteching.com/goffee/docs/routing",children:"routing docs section"})]})]})}function h(e={}){const{wrapper:t}={...(0,r.R)(),...e.components};return t?(0,o.jsx)(t,{...e,children:(0,o.jsx)(d,{...e})}):d(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>i,x:()=>c});var o=n(6540);const r={},s=o.createContext(r);function i(e){const t=o.useContext(s);return o.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:i(e.components),o.createElement(s.Provider,{value:t},e.children)}}}]);