<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Giya Pranata on Medium]]></title>
        <description><![CDATA[Stories by Giya Pranata on Medium]]></description>
        <link>https://medium.com/@pranata.giya12.gp?source=rss-bdd93725348a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*jE1R0aJI_nrH_DTl_wRqMA.jpeg</url>
            <title>Stories by Giya Pranata on Medium</title>
            <link>https://medium.com/@pranata.giya12.gp?source=rss-bdd93725348a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 05:40:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pranata.giya12.gp/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Build Full Stack Login Page FastAPI, React, Postgresql, Tailwindcss.]]></title>
            <link>https://medium.com/@pranata.giya12.gp/build-full-stack-login-page-fastapi-react-postgresql-tailwindcss-6f9d84c6e6b8?source=rss-bdd93725348a------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f9d84c6e6b8</guid>
            <category><![CDATA[login-page]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Giya Pranata]]></dc:creator>
            <pubDate>Wed, 30 Nov 2022 06:21:47 GMT</pubDate>
            <atom:updated>2022-11-30T06:27:31.079Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rMRT88umgJH137O_4vfVEw.jpeg" /></figure><p>Hello Everyone, I hope you all doing well. In this article, we will build a full-stack login web application with JWT token. FastAPI is a modern, high-performance, batteries-included Python web framework that’s perfect for building RESTful APIs. And we use React Js as frontend because react is a powerful JavaScript library whose primary focus is on rendering fast, performant UIs, using one-way data-binding to populate the view.</p><h3>Article Content</h3><ul><li>Use case diagram and Requirements</li><li>Entity Relationship Diagram ERD</li><li>Create Backend</li><li>Create Frontend</li></ul><h4>Use case diagram and Requirements</h4><p>Before implementing the code, we will create a use case first. Here I have made a use case diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ncD_qIqq-JJxhvnU" /></figure><p>Where there are several cases that we will do. First, the user can login to the page. Second, before logging in, user must be register. Third user can change their password. Finally, user can see the profile after logging in.</p><h4>Entity Relationship Diagram ERD</h4><p>After we know the requirements of the system we will make a graphical representation of entities (which will become your tables or ERD) and their relationships to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2wvjYOCEZV9lM6R5" /></figure><h4>Create Backend</h4><p>In this project we will use FastAPI as a backend service. First, let’s create a folder structure in this project as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pEwXnPI7bfwaVvAT" /></figure><ul><li><strong>Controller </strong>: Manage of the REST interface to the business logic</li><li><strong>Repository</strong>: Storage of the entity/model bean in system</li><li><strong>Model</strong>: Model/entity is data structure like table from ERD</li><li><strong>Service</strong>: Business logic implementation</li><li><strong>Media</strong>: Put default photo user when register</li></ul><p>To clarify the work there are several steps that will be used following the steps:</p><ol><li>Create config file from FastAPI to database Postgresql</li><li>Create model ERD</li><li>Create repository</li><li>Create service</li><li>Create controller</li></ol><p>Before we make the project you have to install poetry on your pc or laptop. how to install it, you can directly check here <a href="https://python-poetry.org/">https://python-poetry.org/</a>. Poetry, is a dependency management and packaging tool for Python projects. In other words, poetry will handle the dependencies that you have defined in your pyproject.toml file.</p><p>Now let’s suppose that you are about to start working on a backend project. In this case, you can create one by running poetry new command:</p><pre>$ poetry new backend</pre><p>This command will create a new project under a directory called backend containing the following structure:</p><pre>backend<br>├── pyproject.toml<br>├── README.md<br>├── backend<br>│   └── __init__.py<br>└── tests<br>    └── __init__.py</pre><p>rename folder backend to app and modify name in pyproject.toml file. and the whole folder becomes like this.</p><pre>backend<br>├── pyproject.toml<br>├── README.md<br>├── app<br>│   └── __init__.py<br>└── tests<br>    └── __init__.py</pre><p>and file pyproject.toml become like this.</p><pre>[tool.poetry]</pre><pre>name = &quot;app&quot;<br>version = &quot;0.1.0&quot;<br>description = &quot;&quot;<br>authors = [&quot;lemoncode21 &lt;lemoncode21p@gmail.com&gt;&quot;]<br>readme = &quot;README.md&quot;</pre><p>To start off we need to create a virtual environment and FastAPI</p><pre># Goto backend folder<br>cd backend</pre><pre>#create virtual environment<br>python -m venv ./venv</pre><pre>#activate virtual environment (Windows)<br>.\venv\Scripts\activate</pre><p>after That you can add dependencies fastapi and uvicorn</p><pre>poetry add fastapi uvicorn</pre><p>Let’s head over to our <strong>main.py</strong> and write the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c62a4758f43ac6f226bbcd041fbedebb/href">https://medium.com/media/c62a4758f43ac6f226bbcd041fbedebb/href</a></iframe><p>add poetry script in pyproject.toml file</p><pre>[tool.poetry.scripts]<br>start= &quot;app.main:start&quot;</pre><p>you can run FastAPI using poetry command</p><pre>$ poetry run start</pre><h4>1. Create config file from FastAPI to database Postgresql</h4><p>Let us initialize our database. we use postgresql as database. Before start dont forget install SQLAlchemy, SQLModel as Object Relation Mapping tool and asyncpg, psycopg2 as async connection to postgresql.</p><pre>$ poetry add SQLAlchemy sqlmodel asyncpg psycopg2</pre><p>create config file and write the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93ae094c7ede2138afb86a13d1c31f2f/href">https://medium.com/media/93ae094c7ede2138afb86a13d1c31f2f/href</a></iframe><p>go to main.py we need small improve code as following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d463e182dacaf6731c9c5160739c7387/href">https://medium.com/media/d463e182dacaf6731c9c5160739c7387/href</a></iframe><p>We have completed the entire configuration to the database. Next we will create entities or models with reference to the ERD.</p><h4>2. Create model ERD</h4><p>Let’s head over to folder model.py. We are going to define out models here. We will give just one example in making the model. the model or entities that we will create is the <strong>users</strong> as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/943654d39e89b3ef8ba27f57f4d9dccc/href">https://medium.com/media/943654d39e89b3ef8ba27f57f4d9dccc/href</a></iframe><p>for other models according to ERD, you can see later in the code repository.</p><h4>3. Create Repository</h4><p>Let’s define the database CRUD go to repository folder and create base repository first like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aea621c7cc99f73b7a9e458dbeb3553b/href">https://medium.com/media/aea621c7cc99f73b7a9e458dbeb3553b/href</a></iframe><p>then you can extend the <strong>base_repo.py</strong> function to other repositories such as <strong>users.py</strong> like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d9d07df33b6234191dd12327b8b2cc8/href">https://medium.com/media/6d9d07df33b6234191dd12327b8b2cc8/href</a></iframe><p>other repositories such as roles, person, user role you can add later like the code repository on github. Before we create a login and signup service. we need to generate a jwt token and a jwt bearer. we will write generate token and bearer token in <strong>auth_repo.py.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/20bfbd3d73870eeed8940f3deba10193/href">https://medium.com/media/20bfbd3d73870eeed8940f3deba10193/href</a></iframe><h4>4. Create service</h4><p>There are two services that we will create, namely authentication and user service.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/595a63b3fa3d0f01b2ffce50118e5b49/href">https://medium.com/media/595a63b3fa3d0f01b2ffce50118e5b49/href</a></iframe><p>and this is a users service</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/46d965fb3f51006f6b9c9bac9eeb9206/href">https://medium.com/media/46d965fb3f51006f6b9c9bac9eeb9206/href</a></iframe><h4>5. Create controller or router</h4><p>Next, let’s set up the authentication and users routes, following RESTful best practices:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0786cfca1ab0fac231ccf256684ee8ba/href">https://medium.com/media/0786cfca1ab0fac231ccf256684ee8ba/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c94ce97b1c2b77acd47d7206c354a3c8/href">https://medium.com/media/c94ce97b1c2b77acd47d7206c354a3c8/href</a></iframe><p>We can finally run our application either through the IDE or using the command line with the following command:</p><pre>$ poetry run start</pre><p><strong>Create Frontend</strong></p><p>In this section frontend creation process, I will not explain in detail but only an outline. so the steps in making a frontend:</p><ul><li><strong>First </strong>we create a tailwind react project, you can see the steps for creating a project <a href="https://tailwindcss.com/docs/guides/create-react-app">here</a>.</li><li><strong>Second</strong> we make a login form design, register and forgot password.</li><li><strong>Third</strong> is to integrate each form with the backend.</li></ul><p>Thank you friends for reading this article, I hope it can help you. You can see the whole code <a href="https://github.com/lemoncode21/fastapi-reactjs-loginpage">here </a>and video tutorial <a href="https://youtu.be/xDYWxvwdFko">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f9d84c6e6b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a crud rest api example using node js, express, and postgresql.]]></title>
            <link>https://medium.com/@pranata.giya12.gp/build-a-crud-rest-api-example-using-node-js-express-and-postgresql-bca4eb34c758?source=rss-bdd93725348a------2</link>
            <guid isPermaLink="false">https://medium.com/p/bca4eb34c758</guid>
            <category><![CDATA[postgres]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Giya Pranata]]></dc:creator>
            <pubDate>Sun, 24 Apr 2022 12:47:00 GMT</pubDate>
            <atom:updated>2022-04-24T12:47:00.141Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nbUTdQgG9XxTQFjA" /></figure><p>In this article we will create a simple crud rest api using node js, express, and will connect to the postgresql database. Express is a framework for building web applications on top of Node.js. It simplifies the server creation process that is already available in Node. In case you were wondering, Node allows you to use JavaScript as your server-side language.</p><h4>Structure project.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/0*le0ZjhWvdVxm536a" /></figure><h3>Article Contents</h3><ul><li>Setup nodejs Express</li><li>Create server js</li><li>Create config database</li><li>Create model</li><li>Create controller</li><li>Create router</li><li>Create error handle</li><li>Add unit test</li></ul><h3>1. Setup nodejs Express</h3><p>First, we create a folder:</p><pre>$ mkdir nodejs-postgresql <br>$ cd nodejs-postgresql</pre><p>Next, we initialize the Node.js App with a package.json file:</p><pre>$ npm init  </pre><pre>name: (nodejs-postgresql)  <br>version: (1.0.0)  <br>description: Node.js Restful CRUD API with Node.js, Express and Postgresql <br>entry point: (index.js) server.js <br>test command:  <br>git repository:  <br>keywords:  <br>author: lemoncode21 <br>license: MIT <br>Is this ok? (yes) yes</pre><p>We need to install necessary modules: <strong>express</strong>, <strong>pg</strong>, <strong>pg-hstore</strong>, and <strong>cors</strong>. Run the command:</p><pre>npm install express pg pg-hstore cors express-async-handler --save</pre><p>The package.json file should look like this:</p><pre>{<br>  &quot;name&quot;: &quot;nodejs-postgresql&quot;,<br>  &quot;version&quot;: &quot;1.0.0&quot;,<br>  &quot;description&quot;: &quot;Node.js Restful CRUD API with Node.js, Express and Postgresql&quot;,<br>  &quot;main&quot;: &quot;server.js&quot;,<br>  &quot;scripts&quot;: {<br>     &quot;start&quot;: &quot;node server.js&quot;,<br>  },<br>  &quot;author&quot;: &quot;lemoncode21&quot;,<br>  &quot;license&quot;: &quot;MIT&quot;,<br>  &quot;dependencies&quot;: {<br>    &quot;cors&quot;: &quot;^2.8.5&quot;,<br>    &quot;express&quot;: &quot;^4.17.3&quot;,<br>    &quot;pg&quot;: &quot;^8.7.3&quot;,<br>    &quot;pg-hstore&quot;: &quot;^2.3.4&quot;,<br>  }<br>}</pre><h3>2. Create server js</h3><p>In the root folder, let’s create a new server.js file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6d06893b28dc05e63cfd281cdcd56e5c/href">https://medium.com/media/6d06893b28dc05e63cfd281cdcd56e5c/href</a></iframe><h3>3. Create config database</h3><p>add new module <strong>sequelize</strong></p><pre>npm install sequelize</pre><p>create new folder config and create new file <em>config.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9ee891f0fcb7e7b6f053233ee492930/href">https://medium.com/media/c9ee891f0fcb7e7b6f053233ee492930/href</a></iframe><h3>4.Create model</h3><p>create new folder model and create new file <em>Task.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b1ad628b0c16dc96f390bc0713acbf97/href">https://medium.com/media/b1ad628b0c16dc96f390bc0713acbf97/href</a></iframe><h3>5.Create controller</h3><p>create new folder controller and create new file <em>TaskController.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cc6f9f1fe10ed5723064d44ddc9744f/href">https://medium.com/media/4cc6f9f1fe10ed5723064d44ddc9744f/href</a></iframe><h3>6.Create router</h3><p>create new folder router and create new file <em>TaskRouter.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a538981c3ed0981e3b4a6b4ea0a3d9d/href">https://medium.com/media/0a538981c3ed0981e3b4a6b4ea0a3d9d/href</a></iframe><h3>7. Create Global error handler</h3><p>create new folder middleware and create new file <em>ErrorHandler.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd43028db5477b28121c41e72cb872bc/href">https://medium.com/media/cd43028db5477b28121c41e72cb872bc/href</a></iframe><p>we need to add some code in <em>server.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cb30cc6f0c7710b0f63bcdd33219c988/href">https://medium.com/media/cb30cc6f0c7710b0f63bcdd33219c988/href</a></iframe><h3>8. Add unit test</h3><p>Before we make unit tests there are several modules that we must add as follows</p><pre>npm i chai chai-http mocha dotenv</pre><p>after that add the nodemon module in the dev env</p><pre>npm install --save-dev nodemon</pre><p>and finally file <em>package.json</em> look like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/95eb7a27a768be2ece6842f49228d43b/href">https://medium.com/media/95eb7a27a768be2ece6842f49228d43b/href</a></iframe><p>Now we will add multi environment <em>development.env</em> and <em>test.env</em></p><pre>NODE_ENV=development<br>PORT=8080</pre><pre>DATABASE_NAME=postgres<br>DATABASE_HOST=localhost<br>DATABASE_USERNAME=postgres<br>DATABASE_PASSWORD=postgres</pre><p>and <em>test.env</em></p><pre>NODE_ENV = test<br>PORT = 8080</pre><pre>DATABASE_NAME = postgres_test<br>DATABASE_HOST = localhost<br>DATABASE_USERNAME = postgres<br>DATABASE_PASSWORD = postgres</pre><p>update file <em>config.js</em> file to be like this</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e80131e7095b040568412184c96aca58/href">https://medium.com/media/e80131e7095b040568412184c96aca58/href</a></iframe><p>add file folder <em>test</em> and file <em>Task.test.js</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3938e53310f39ccd44ae4d713886ad8e/href">https://medium.com/media/3938e53310f39ccd44ae4d713886ad8e/href</a></iframe><p>Finally we have finished creating the code. To run it simply by doing the following command:</p><pre>npm run dev</pre><p>To do testing, you can use the following command:</p><pre>npm run test</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bca4eb34c758" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Develop a chat application using React js, FastAPI and websocket]]></title>
            <link>https://medium.com/@pranata.giya12.gp/develop-a-chat-application-using-react-js-fastapi-and-websocket-5660143c4f80?source=rss-bdd93725348a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5660143c4f80</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[chat]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[websocket]]></category>
            <dc:creator><![CDATA[Giya Pranata]]></dc:creator>
            <pubDate>Thu, 03 Mar 2022 06:25:18 GMT</pubDate>
            <atom:updated>2022-03-03T06:25:18.361Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*b9Zuu_nc5EkmOSSs" /></figure><p>In this article, I will guide you to build chat application using React, FastAPI, and Websocket. WebSocket is a popular communication protocol (TCP) that enables seamless full-duplex communication (two-way communication) between client and server. In other words, it allows websites send and receive data without delay. WebSockets do not use the http:// or https:// scheme (because they do not follow the HTTP protocol). Instead, WebSocket URIs use a new scheme ws: or wss: (recommended) for a secure WebSocket. Web developers use WebSocket to build chat applications, multiplayer games, SDKs, or user interfaces exposing server-side services in real-time and so much more.</p><h3>Article Contents</h3><ul><li>Setup backend Fastapi</li><li>Create connection manager</li><li>Create router websocket</li><li>Setup frontend React Js</li><li>Design chat application</li><li>Integration Backend and Frontend</li><li>Test chat application</li></ul><h3>1. Setup backend FastAPI</h3><p>To start off we need to create a virtual environment and FastAPI.</p><pre># Create dir<br>mkdir backend</pre><pre>cd backend</pre><pre>#create virtual environment<br>python -m venv ./venv</pre><pre>#activate virtual environment (Windows)<br>.\venv\Scripts\activate</pre><p>after That you can install fastapi</p><pre>pip install fastapi uvicorn</pre><p>Let’s head over to our main.py and write the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/84490c57853239584e89e45a5f6c9486/href">https://medium.com/media/84490c57853239584e89e45a5f6c9486/href</a></iframe><h3>2. Create connection manager</h3><p>Creating a manager class which will be responsible for sending messages between the connected users and also maintaining their connections. We add it to the <strong>main.py</strong> file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4cc06bd7da2514b8051958e695f6f158/href">https://medium.com/media/4cc06bd7da2514b8051958e695f6f158/href</a></iframe><p>Before we create endpoint, we will add CORS in <strong>main.py</strong> So that this service can be accessed by frontend.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bc8f71adcdf71eb9aaa2419898128ab/href">https://medium.com/media/2bc8f71adcdf71eb9aaa2419898128ab/href</a></iframe><h3>3. Create router websocket</h3><p>We now have to create a websocket endpoint from where we can call our manager.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/61b7233c7f3e387dcb0868ea375011b4/href">https://medium.com/media/61b7233c7f3e387dcb0868ea375011b4/href</a></iframe><p>Finally we done create backend service and this is the whole <strong>main.py</strong> file</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/348c55a1e06be10e34a95c8f6b4db3ca/href">https://medium.com/media/348c55a1e06be10e34a95c8f6b4db3ca/href</a></iframe><h3>4. Setup frontend React Js</h3><p>The first step to create the front end of our applications will be to initialize the React application. You can easily do this with the command:</p><pre>yarn create react-app frontend</pre><p>frontend structure project</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/337/0*YpnlNVPuCSLlrSeh" /></figure><h3>5. Design chat application</h3><p>Now let’s write the code in <strong>App.js</strong> according to the design below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*LCMHl664T2VB-gIQ" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a7af21a3801af1e4ff09819680cfb31/href">https://medium.com/media/8a7af21a3801af1e4ff09819680cfb31/href</a></iframe><p>And this css file write in <strong>App.css</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/616b4e7f5f318aa3b10470ac5cbe628e/href">https://medium.com/media/616b4e7f5f318aa3b10470ac5cbe628e/href</a></iframe><h3>6. Integration Backend and Frontend</h3><p>To Integration backend and frontend we need to add some function connect to websocket, like code below</p><pre>const [clientId, setClienId] = useState(<br>    Math.floor(new Date().getTime() / 1000)<br>  );</pre><pre>const [chatHistory, setChatHistory] = useState([]);<br>  const [isOnline, setIsOnline] = useState(false);<br>  const [textValue, setTextValue] = useState(&quot;&quot;);<br>  const [websckt, setWebsckt] = useState();</pre><pre>const [message, setMessage] = useState([]);<br>  const [messages, setMessages] = useState([]);</pre><pre>useEffect(() =&gt; {<br>    const url = &quot;ws://localhost:8000/ws/&quot; + clientId;<br>    const ws = new WebSocket(url);</pre><pre>ws.onopen = (event) =&gt; {<br>      ws.send(&quot;Connect&quot;);<br>    };</pre><pre>// recieve message every start page<br>    ws.onmessage = (e) =&gt; {<br>      const message = JSON.parse(e.data);<br>      setMessages([...messages, message]);<br>    };</pre><pre>setWebsckt(ws);<br>    //clean up function when we close page<br>    return () =&gt; ws.close();<br>  }, [message,messages]);</pre><pre>const sendMessage = () =&gt; {<br>    websckt.send(message);<br>    // recieve message every send message<br>    websckt.onmessage = (e) =&gt; {<br>      const message = JSON.parse(e.data);<br>      setMessages([...messages, message]);<br>    };<br>    setMessage([]);<br>  };</pre><p>so the final code <strong>App.js</strong> like here</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/aa21654ccd4dd9d6a1c7e76e966290cf/href">https://medium.com/media/aa21654ccd4dd9d6a1c7e76e966290cf/href</a></iframe><h3>7. Test chat application</h3><p>To test application we just need open two browser and send chat.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/0*4p9hbgbp45BCW2Ya.gif" /></figure><p>Finally finished that’s how to make a simple web chat project using React js FastAPI and websocket.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5660143c4f80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[FastAPI JWT authentication]]></title>
            <link>https://medium.com/@pranata.giya12.gp/fastapi-jwt-authentication-2f333cf96ada?source=rss-bdd93725348a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f333cf96ada</guid>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[jwt-token]]></category>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Giya Pranata]]></dc:creator>
            <pubDate>Mon, 14 Feb 2022 03:41:35 GMT</pubDate>
            <atom:updated>2022-02-14T03:53:01.619Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*sSCX-aqtlloWAtFh" /></figure><p>In this project we will implementation JWT token in FastAPI. Implementing authorization can be useful, as it provides the client access to a specific set of functions, actions, data, etc. JWT (or JSON web tokens) are simply base64 strings that encode some information about the client. These tokens are signed using a secret key or a public/private key. We will implement the former method. Essentially, when the client is logged in, the server sends back a response with a signed token.</p><h3>Article Content</h3><ul><li>Create project FastAPI</li><li>Create Main app</li><li>Create Config</li><li>Create models</li><li>Create crud repository</li><li>Create schema</li><li>Create Generate Token</li><li>Create Authentication router</li><li>Lock router with JWT token</li></ul><h3>1.Create project FastAPI</h3><p>To start off we need to create a virtual environment and FastAPI.</p><pre># Create dir<br>mkdir fastapi-authentication-service</pre><pre>cd fastapi-authentication-service</pre><pre>#create virtual environment<br>python -m venv ./venv</pre><pre>#activate virtual environment (Windows)<br>.\venv\Scripts\activate</pre><p>after That you can install fastapi</p><pre>pip install fastapi</pre><p>We will need an ASGI (Asynchronous Server Gateway Interface) server, in this case we will use Uvicorn.</p><pre>pip install uvicorn</pre><h3>2.Create Main App</h3><p>Let’s head over to our <strong>main.py</strong> and write the following code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d4d97db9282c33ac623d3b9b2b9aa2b3/href">https://medium.com/media/d4d97db9282c33ac623d3b9b2b9aa2b3/href</a></iframe><p>To run this, execute this from your commandline/terminal:</p><pre>uvicorn main:app --reload</pre><h3>3.Create Config</h3><p>Let us initialize our database. we use postgresql as database. Before start dont forget install SQLAlchemy as Object Relation Mapping tool.</p><pre>pip install SQLAlchemy</pre><p>go to <strong>config.py</strong> and write the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1505e6f0f43678c72c27f550b2a183db/href">https://medium.com/media/1505e6f0f43678c72c27f550b2a183db/href</a></iframe><h3>4.Create Model</h3><p>Let’s head over to <strong>models.py</strong>. We are going to define out models here.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b597d2af93f936146511eb4808be3030/href">https://medium.com/media/b597d2af93f936146511eb4808be3030/href</a></iframe><p>Let’s make additions in <strong>main.py</strong> file</p><pre>#add import <br>import models from config import engine  </pre><pre>models.Base.metadata.create_all(bind=engine)</pre><p>Because we are using postgresql database we need to add psycopg2 library to connect to that database.</p><pre>pip install psycopg2</pre><h3>5.Create crud repository</h3><p>Let’s define the database CRUD go to <strong>repository.py</strong> and write the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07dc0bc8f1882e28f84ce8f160fb1334/href">https://medium.com/media/07dc0bc8f1882e28f84ce8f160fb1334/href</a></iframe><h3>6.Create schema</h3><p>Schema is a pydantic model that is placed as a request or response object to a controller/endpoint. it’s time we write the pydantic model in the file <strong>schema.py</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/082f4ea7c7e09fa38557b6967bc8a462/href">https://medium.com/media/082f4ea7c7e09fa38557b6967bc8a462/href</a></iframe><h3>7.Create Generate Token</h3><p>Before we create a login and signup service. we need to generate a JWT token and a JWT bearer. we will write generate token and bearer token in <strong>repository.py</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a7b6e36385992f55880db3417d428c17/href">https://medium.com/media/a7b6e36385992f55880db3417d428c17/href</a></iframe><p>After writing JWTRepo and JWTBearer classes in the repository it becomes as below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/468e449a69c62c86bd9bfb2325eb7280/href">https://medium.com/media/468e449a69c62c86bd9bfb2325eb7280/href</a></iframe><h3>8.Create Router</h3><p>Next, let’s set up the authentication routes, following RESTful best practices:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e0249ceda8588e3c16b6fab8360f09b0/href">https://medium.com/media/e0249ceda8588e3c16b6fab8360f09b0/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bca284b36cd8dafbf6f1e53b537772f3/href">https://medium.com/media/bca284b36cd8dafbf6f1e53b537772f3/href</a></iframe><h3>9.Lock router with JWT token</h3><p>Now we make an example of how to lock the router with JWT token. we create one sample with retrieve all user. for example as below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37bf778926f346fd03c2b7fb615aaf1d/href">https://medium.com/media/37bf778926f346fd03c2b7fb615aaf1d/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8516ef9288d8a44d1ff56b5140a168d2/href">https://medium.com/media/8516ef9288d8a44d1ff56b5140a168d2/href</a></iframe><p>so the whole <strong>router.py</strong> writing is like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/cd83e411541dff1d5c5660cd800405d6/href">https://medium.com/media/cd83e411541dff1d5c5660cd800405d6/href</a></iframe><p>Let’s back to main.py to add router write the following:</p><pre>import router</pre><pre>app.include_router(router.router)</pre><p>and finally <strong>main.py</strong> file like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38f86c29303346239800f3588ec0d690/href">https://medium.com/media/38f86c29303346239800f3588ec0d690/href</a></iframe><p>find this code <a href="https://github.com/lemoncode21/Fastapi-JWTtoken.git">here</a>, and If you want to see the steps in more detail can be seen in this video.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FFN6mR6TAZN4%3Fstart%3D289%26feature%3Doembed%26start%3D289&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DFN6mR6TAZN4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FFN6mR6TAZN4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/827909534ba74c391feaf5765de4ddda/href">https://medium.com/media/827909534ba74c391feaf5765de4ddda/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f333cf96ada" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring boot docker application deployment using Jenkins pipeline]]></title>
            <link>https://medium.com/@pranata.giya12.gp/spring-boot-docker-application-deployment-using-jenkins-pipeline-5b3bee83e5e6?source=rss-bdd93725348a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b3bee83e5e6</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Giya Pranata]]></dc:creator>
            <pubDate>Fri, 04 Feb 2022 04:06:50 GMT</pubDate>
            <atom:updated>2022-02-21T03:30:07.419Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*0UsSGejC06wLW7wj" /></figure><p>Hi everyone, on this occasion we will discuss how to deploy spring boot docker application using Jenkins pipeline.</p><h3>Article Content:</h3><ul><li>Install plugin gitlab, maven, and docker.</li><li>Add user gitlab in jenkins.</li><li>Init springboot project.</li><li>Add Jenkinsfile and pipeline script.</li><li>Add Dockerfile.</li><li>Create project repo gitlab.</li><li>Create job chose pipeline project.</li><li>Build Project.</li></ul><h3>Folder structure</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/0*yi6ojktaLxDBXY-d" /></figure><h3>1.Install plugin gitlab, maven, and docker.</h3><p>After installed Jenkins in server or pc, add or install plugin gitlab, maven, and docker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*AB76z9xnOFyV14JI" /></figure><h3>2.Add user Gitlab in Jenkins.</h3><p>Add user Gitlab and Jenkins to get credentials.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kcc_waJW6tttIuNN" /></figure><h3>3.Init Springboot project.</h3><p>To Create spring boot project, Open the Spring initializr <a href="https://start.spring.io/">https://start.spring.io</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*t4sRTKvi7Geae74e" /></figure><h3>4.Add Jenkins file and pipeline script.</h3><p>Add Jenkins file to run pipeline for auto deploy.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dffe768f492d2c71f498208a5aa49448/href">https://medium.com/media/dffe768f492d2c71f498208a5aa49448/href</a></iframe><h3>5. Add Dockerfile.</h3><p>Add dockerfile to build docker using dockerfile.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa86a937faf0d4084b942ea045e6714a/href">https://medium.com/media/fa86a937faf0d4084b942ea045e6714a/href</a></iframe><h3>6.Create project repo Gitlab.</h3><p>Create a repository project in gitlab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RtTFnpuvRnDQW46h" /></figure><h3>7.Create job chose pipeline project.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kq2d0qtkFUU_CqYD" /></figure><h3>8.Build Project.</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Ep75JF9CaoOsXaIH" /></figure><p>If you want to see the steps in more detail can be seen in this video</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FPvwOxdyvSsg%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPvwOxdyvSsg&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FPvwOxdyvSsg%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/2a0aaf145dcf38ece7a94d82c54f4c3b/href">https://medium.com/media/2a0aaf145dcf38ece7a94d82c54f4c3b/href</a></iframe><p>Check my code article project</p><p><a href="https://www.lemoncode21.com/Blog/spring-boot-docker-application-deployment-using-jenkins-pipeline">https://www.lemoncode21.com/Blog/spring-boot-docker-application-deployment-using-jenkins-pipeline</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b3bee83e5e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cara Install Docker di Ubuntu]]></title>
            <link>https://medium.com/@pranata.giya12.gp/cara-install-docker-di-ubuntu-39ec98816d13?source=rss-bdd93725348a------2</link>
            <guid isPermaLink="false">https://medium.com/p/39ec98816d13</guid>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[devops]]></category>
            <dc:creator><![CDATA[Giya Pranata]]></dc:creator>
            <pubDate>Wed, 07 Oct 2020 08:19:10 GMT</pubDate>
            <atom:updated>2020-10-07T08:40:02.029Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b4-sxIK2AlJl6RJ3dtE13g.png" /></figure><p>Halo gais mamang mau titip jejak lagi cara install docker di ubuntu. Sebelum mulai mau dikit ceritalah apa itu Docker. Docker adalah teknologi open-source yang berfungsi untuk men-<em>deploy</em> aplikasi melalui <a href="https://www.docker.com/resources/what-container"><strong>container</strong></a>. Penting banget di zaman now paham docker soalnya ini digunakan untuk deploy aplikasi diserver atau di pc kita sendiri gak pake ribet.</p><p>Contohnya kaya gini ini: kita dah develop aplikasi terus build &amp; run di local bekerja normal nih, tapi waktu ditaro di server errorlah terkadang diserver gak ada library-nya atau kurang install aplikasi lain lah yang diperlukan untuk aplikasi kita. <em>Nah</em>, dengan adanya Docker, masalah terselesaikan. Baiklah langsung aja kita mulai taperlu banyak “<em>cingcong”</em> lagi gas keun!!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X1ukuqvYib9eadD8sD5pdQ.png" /></figure><h3>Update Dulu</h3><p>Biasanya sebelum install update &amp; upgrade dulu biar kaya orang-orang hiya hiya. alasan lain biar aman waktu install Docker. Langsung ketik aja:</p><pre>sudo apt update<br>sudo apt upgrade</pre><h3>Install Package</h3><p>Install package ketik perintah ini:</p><pre>sudo apt-get install curl apt-transport-https ca-certificates software-properties-common</pre><p>Berikut deskripsinya:</p><ul><li><strong>apt-transport-https</strong> — package manager akan mentransfer file dan data melalui https.</li><li><strong>ca-certificates</strong> — web browser dan sistem akan mengecek sertifikat keamanan.</li><li><strong>curl</strong> — transfer data.</li><li><strong>software-properties-common</strong> — menambahkan script untuk mengelola software.</li></ul><h3>Menambahkan Repositori Docker</h3><p>Udah ada nih repo dockernya di pc kita, langsung ketik aja buat intallasi resmi.</p><p>Tambahkan GPG key:</p><pre>curl -fsSL <a href="https://download.docker.com/linux/ubuntu/gpg">https://download.docker.com/linux/ubuntu/gpg</a> | sudo apt-key add -</pre><p>Tambahkan repo:</p><pre>sudo add-apt-repository &quot;deb [arch=amd64] <a href="https://download.docker.com/linux/ubuntu">https://download.docker.com/linux/ubuntu</a> $(lsb_release -cs) stable&quot;</pre><p>update repo:</p><pre>sudo apt update</pre><p>Jalankan perintah ini untuk instalasi melalui Docker repo:</p><pre>apt-cache policy docker-ce</pre><p>Output:</p><pre>docker-ce:<br>   Installed: (none)<br>   Candidate: 16.04.1~ce~4-0~ubuntu<br>   Version table:<br>      16.04.1~ce~4-0~ubuntu 500<br>           500 <a href="https://download.docker.com/linux/ubuntubionic/stableamd64packages">https://download.docker.com/linux/ubuntubionic/stableamd64packages</a></pre><p>Sip repo dah ada.</p><h3>Install Docker Ubuntu</h3><p>Langsung install dockernya di ubuntu:</p><pre>sudo apt install docker-ce</pre><h3>Cek Status Docker</h3><p>Waktunya cek status ketik :</p><pre>sudo systemctl status docker</pre><p>output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/643/1*XiJB1B5Lye1aiwXlpbo4gg.png" /></figure><p>Nah installasi docker di ubuntu beres.</p><h3>Waktunya Test Docker</h3><p>Coba buka terminal terus ketik:</p><pre>docker run hello-world</pre><p>output:</p><pre>docker: Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.35/containers/create: dial unix /var/run/docker.sock: connect: permission denied.See &#39;docker run --help&#39;.</pre><p>kalau kaya gini berarti dokcernya harus dijalanin pake sudo atau as root.</p><pre>sudo docker run hello-world</pre><p>Nah tapikan ribet ya jalanin kaya gitu apa-apa kudu sudo. Setelah membaca dokumentasi dari docker ada beberapa hal yang harus ditambahakan yaitu kalain harus menambahkan docker group.</p><ol><li>Membuat docker group kalau belum ada.</li></ol><pre> sudo groupadd docker </pre><p>2. Tambahkan user kalian kedalam docker group ketik aja.</p><pre> sudo usermod -aG docker $USER</pre><p>3. Nah sudah bisa langsung coba ketik aja:</p><pre> docker run hello-world</pre><p>Kalau masih dapet error gak usah khawatir restart aja dockernya:</p><pre>sudo systemctl restart docker</pre><p>kalau gak kalian bisa restart PC-nya sudah deh beres. Oke thank you titip jejak dulu disini sobat internet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=39ec98816d13" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cara Install Golang di Ubuntu]]></title>
            <link>https://medium.com/@pranata.giya12.gp/cara-install-golang-di-ubuntu-2b4e97156103?source=rss-bdd93725348a------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b4e97156103</guid>
            <category><![CDATA[install]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Giya Pranata]]></dc:creator>
            <pubDate>Wed, 07 Oct 2020 07:45:59 GMT</pubDate>
            <atom:updated>2020-10-07T08:25:51.690Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*VamrqX0eIU-EmrLlXz2r_w.png" /></figure><p>Hai gais kali ini Mamang mau simpen jejak cara install Golang di ubuntu. Sebelum install mau sedikit cerita apa itu Golang. Go-language atau Go adalah bahasa pemograman yang dibuat oleh Google pada sekitar tahun 2007. Bahasa ini juga populer digunakan oleh banyak aplikasi seperti Docker, Kubernetes, dll.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*c5nsW1mn-PE4cy3t73oHNg.png" /></figure><p>Di Post kali ini Ane akan mencoba install Go kedalam Ubuntu, ini juga berlaku bagi Anda pengguna Windows Linux Subsystem (WSL).</p><p>Ada dua cara kalau mau install Golang di ubuntu yaitu:</p><ol><li>Bisa install menggunakan <em>Ubuntu Package Manager.</em></li><li>Bisa install dengan <em>binary distribution.</em></li></ol><h3>Cek Versi Ubuntu</h3><p>Biasanya Ane check dulu versi Linux yang dipakai buka terminal langsung aja ketik.</p><pre>lsb_release -a</pre><p>output:</p><pre>// Output<br>No LSB modules are available.<br>Distributor ID: Ubuntu<br>Description:    Ubuntu 18.04.1 LTS<br>Release:        18.04<br>Codename:       bionic</pre><p>Nah outputnya adalah versi yang kita punya adalah 18.04 dan LTS adalah kepanjangan dari Long Term Support.</p><h3>1. Install via apt-get</h3><p>Buka terminal langsung ketik aja command dibaawah.</p><pre>sudo apt-get update<br>sudo apt-get upgrade<br>sudo apt-get install golang-go</pre><p>kalau udah coba check versi go nya.</p><pre>go version</pre><p>output:</p><pre>// Output<br>go version go1.10.4 linux/amd64</pre><h3>2. Install via Binary Distribution</h3><p>Nah kalau kalian mau install pake binary distribution bisa boleh. cocok buat anak yang tukang ngulik,kalau Ane mah kagak hiya hiya.</p><p>Pertama buka webnya go dengan url ini <a href="https://golang.org/dl/">https://golang.org/dl/</a> dan pilih release yang kompatibel dengan OS Anda.</p><ul><li>go1.13.1.linux-amd64.tar.gz</li></ul><p>Sekarang buka terminal Anda, lakukan download dan extract di folder saat ini.</p><pre>wget https://dl.google.com/go/go1.13.1.linux-amd64.tar.gz<br>sudo tar -xvf go1.13.1.linux-amd64.tar.gzz</pre><p>Sekarang kita punya sebuah folder bernama /go di lokasi direktori saat ini. Pindahkan lokasi nya ke /usr/local/</p><pre>sudo mv go /usr/local</pre><h3>Set Environments</h3><p>Dan langkah terakhir adalah menambahkan nya kedalam global variable melalui file .bashrc atau .profile. kalau bingung cari file .bashrc atau .profile di home folder kalian /home klik view -&gt; show hidden file</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*bhO4zR2ae0jScB1Pl084Rw.png" /></figure><p>terus open aja bebas pakai editor apa yang penting harus Open as root atau pakai terminal ketik begini.</p><pre>sudo nano ~/.bashrc</pre><p>Scroll down dan tambahkan dibaris paling akhir kaya begini.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*uRxlepIia3_CPYOHuRCkUg.png" /></figure><p>atau kalau kalian pakai terminal ketik aja.</p><pre># Go Global variables<br>export GOROOT=/usr/local/go<br>export GOPATH=$HOME/go<br>export PATH=$GOPATH/bin:$GOROOT/bin:$PATH</pre><p>Kalau udah exit aja sambil save atau kalu pakai terminalsimpan dengan Ctrl + o lalu exit dengan Ctrl + x</p><p>Update sesi saat ini dengan me-load config yang barusan kita ubah dengan perintah</p><pre>source ~/.bashrc</pre><h3>Check Versi Go</h3><p>kalau udah coba check versi go nya.</p><pre>go version</pre><p>output:</p><pre>// Output<br>go version go1.10.4 linux/amd64</pre><p>Dah sip beres titip jejak dulu disini sobat internet.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b4e97156103" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>