<?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 Kuzey Köse on Medium]]></title>
        <description><![CDATA[Stories by Kuzey Köse on Medium]]></description>
        <link>https://medium.com/@kuzeykose?source=rss-a9c3c383ed69------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*uyQjCSxiC-Bl-wOxGkD0gg.jpeg</url>
            <title>Stories by Kuzey Köse on Medium</title>
            <link>https://medium.com/@kuzeykose?source=rss-a9c3c383ed69------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:03:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kuzeykose/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[Restful API with Go (Gin)]]></title>
            <link>https://kuzeykose.medium.com/restful-api-with-go-gin-80abb49a226c?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/80abb49a226c</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[go]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Thu, 30 Dec 2021 20:09:22 GMT</pubDate>
            <atom:updated>2021-12-30T20:09:22.865Z</atom:updated>
            <content:encoded><![CDATA[<p>In this blog, we are developing a restful api with you. Little bit of instruction about what is rest is crucial. Then, continuing with the developing API is our main task.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VStEGWJRRFZXIBXpe8ZmwQ.jpeg" /></figure><p>What is Rest API? (<strong>RE</strong>presentational <strong>S</strong>tate <strong>T</strong>ransfer)</p><p>An <strong>API</strong> is an application programming interface. It is consists of a set of rules and used to allow programs to talk to each other. <strong>REST</strong> determines how the API looks like. When the developers create their <strong>API</strong>, they follow the set of constraints. This brings some specific URLs to get a piece of data. Each URL is called a request. The data sent back to you is called a response.</p><p>Our programming language is Go. Beside, Gin Web Framework helps us. I created a serie which is learning go from documentation. This serie includes 5 basic blog to understand basis of Go. If you currently new, It might be good for you. Let’s start.</p><blockquote><em>Gin simplifies many coding tasks associated with building web applications, including web services. In this tutorial, you’ll use Gin to route requests, retrieve request details, and marshal JSON for responses.</em></blockquote><p>We’ll build a task creator app API. Each of the task will be consist of id, title, person and information. Everybody can add a task and read all tasks. Directly, we can say that we are designing endpoints. 🥳</p><pre>/task<br>  - GET  - get list of all task<br>  - POST - Add a new task</pre><pre>/task<br>  - Get task by ID</pre><p>We designed how it looks like. Let’s fun part begins. (In here, I used macOS and iterm2 application. If you are a windows user, you can continue with cmd. Linux is same as macOS.)</p><p>Open a terminal and create a folder where you want — I created on Desktop. Then, initialize the go. Open this folder in text editor.</p><pre>// terminal<br>$ cd Desktop<br>$ mkdir task-app-web<br>$ cd task-app-web<br>$ go mod init example/task-app-web<br>$ touch main.go</pre><pre>// main.go<br>package main</pre><pre>type <strong>task struct</strong> { <br>	ID          string `json:&quot;id&quot;` // we will use json so we need specify what a field’s name should be<br>	Title       string `json:&quot;title&quot;`<br>	Person      string `json:&quot;artist&quot;`<br>	Information string `json:&quot;information&quot;`<br>}</pre><pre>// Also we can create a simple data. In real life, the data come from database.<br>// In here, we will store data in localy.</pre><pre>var <strong>tasks</strong> = <strong>[]task</strong>{<br>	{ID: &quot;BS-1&quot;, Title: &quot;Create an API&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Create a simple task api that people create some tasks and reach all of the task.&quot;},</pre><pre>	{ID: &quot;BS-2&quot;, Title: &quot;Write a blog&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Write a blog that people who interested in Go can write create their API.&quot;},</pre><pre>	{ID: &quot;BS-3&quot;, Title: &quot;Make a coffe for us&quot;, Person: &quot;John&quot;, Information: &quot;29.12.2021 we have a coffe talk session. Can we make a coffe for us?&quot;},</pre><pre>	{ID: &quot;BS-4&quot;, Title: &quot;Order some food&quot;, Person: &quot;May&quot;, Information: &quot;Order some food for lunch.&quot;},<br>}</pre><pre>func <strong>main()</strong> {}</pre><p>In here, we describe our objects how to look like. The task struct shows us parameters, and tasks is a slice that inholds task. Now, we need to use gin framework for using GET HTTP method. Firstly, import the packages, then write a function which name is getTask(). We will use getTask() function insede the router.GET() in main function. (Don’t panic, we will see each of them)</p><pre>// main.go<br>package main</pre><pre>import (<br>    &quot;net/http&quot;</pre><pre>    &quot;github.com/gin-gonic/gin&quot;<br>)</pre><pre>type task struct { <br>	ID          string `json:&quot;id&quot;` // we will use json so we need specify what a field’s name should be<br>	Title       string `json:&quot;title&quot;`<br>	Person      string `json:&quot;artist&quot;`<br>	Information string `json:&quot;information&quot;`<br>}</pre><pre>// Also we can create a simple data. In real life, the data come from database.<br>// In here, we will store data in localy.<br>var tasks = []task{<br>	{ID: &quot;BS-1&quot;, Title: &quot;Create an API&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Create a simple task api that people create some tasks and reach all of the task.&quot;},<br>	{ID: &quot;BS-2&quot;, Title: &quot;Write a blog&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Write a blog that people who interested in Go can write create their API.&quot;},<br>	{ID: &quot;BS-3&quot;, Title: &quot;Make a coffe for us&quot;, Person: &quot;John&quot;, Information: &quot;29.12.2021 we have a coffe talk session. Can we make a coffe for us?&quot;},<br>	{ID: &quot;BS-4&quot;, Title: &quot;Order some food&quot;, Person: &quot;May&quot;, Information: &quot;Order some food for lunch.&quot;},<br>}</pre><pre>// getTasks responds with the list of all albums as JSON.<br><strong>func getTasks(c *gin.Context) {<br>    c.IndentedJSON(http.StatusOK, tasks)<br>}</strong></pre><pre>func main() {}</pre><p>In main function, we need to create a router with using gin. Inside gin, Default() function helps up to create a simple router (<a href="https://pkg.go.dev/github.com/gin-gonic/gin#Default">https://pkg.go.dev/github.com/gin-gonic/gin#Default</a>). And, use the GET function to associate the GET HTTP method.</p><pre>// main.go<br>package main</pre><pre>import (<br>    &quot;net/http&quot;</pre><pre>    &quot;github.com/gin-gonic/gin&quot;<br>)</pre><pre>type task struct { <br>	ID          string `json:&quot;id&quot;` // we will use json so we need specify what a field’s name should be<br>	Title       string `json:&quot;title&quot;`<br>	Person      string `json:&quot;artist&quot;`<br>	Information string `json:&quot;information&quot;`<br>}</pre><pre>// Also we can create a simple data. In real life, the data come from database.<br>// In here, we will store data in localy.<br>var tasks = []task{<br>	{ID: &quot;BS-1&quot;, Title: &quot;Create an API&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Create a simple task api that people create some tasks and reach all of the task.&quot;},<br>	{ID: &quot;BS-2&quot;, Title: &quot;Write a blog&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Write a blog that people who interested in Go can write create their API.&quot;},<br>	{ID: &quot;BS-3&quot;, Title: &quot;Make a coffe for us&quot;, Person: &quot;John&quot;, Information: &quot;29.12.2021 we have a coffe talk session. Can we make a coffe for us?&quot;},<br>	{ID: &quot;BS-4&quot;, Title: &quot;Order some food&quot;, Person: &quot;May&quot;, Information: &quot;Order some food for lunch.&quot;},<br>}</pre><pre>// getTasks responds with the list of all albums as JSON.<br>func getTasks(c *gin.Context) {<br>    c.IndentedJSON(http.StatusOK, tasks)<br>}</pre><pre>func main() {<br>    <strong>router := gin.Default()</strong><br>   <strong> router.GET(&quot;/albums&quot;, getTasks)</strong></pre><pre>    <strong>router.Run(&quot;localhost:8080&quot;)</strong><br>}</pre><blockquote><em>Run attaches the router to a http.Server and starts listening and serving HTTP requests. It is a shortcut for http.ListenAndServe(addr, router) Note: this method will block the calling goroutine indefinitely unless an error happens. (</em><a href="https://pkg.go.dev/github.com/gin-gonic/gin#Engine.Run"><em>https://pkg.go.dev/github.com/gin-gonic/gin#Engine.Run</em></a><em>)</em></blockquote><pre>// terminal<br>$ go get .<br>go get: added github.com/gin-gonic/gin<br>$ go run .<br>$ curl &lt;http://localhost:8080/tasks&gt;</pre><p>So, we can reach the tasks data with GET request. Now, adding a new task in tasks our second target. It can be called by handler to add a new item. postTask is new function to append sent data to tasks.</p><pre>// main.go<br>package main</pre><pre>import (<br>    &quot;net/http&quot;</pre><pre>    &quot;github.com/gin-gonic/gin&quot;<br>)</pre><pre>type task struct { <br>	ID          string `json:&quot;id&quot;` // we will use json so we need specify what a field’s name should be<br>	Title       string `json:&quot;title&quot;`<br>	Person      string `json:&quot;artist&quot;`<br>	Information string `json:&quot;information&quot;`<br>}</pre><pre>// Also we can create a simple data. In real life, the data come from database.<br>// In here, we will store data in localy.<br>var tasks = []task{<br>	{ID: &quot;BS-1&quot;, Title: &quot;Create an API&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Create a simple task api that people create some tasks and reach all of the task.&quot;},<br>	{ID: &quot;BS-2&quot;, Title: &quot;Write a blog&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Write a blog that people who interested in Go can write create their API.&quot;},<br>	{ID: &quot;BS-3&quot;, Title: &quot;Make a coffe for us&quot;, Person: &quot;John&quot;, Information: &quot;29.12.2021 we have a coffe talk session. Can we make a coffe for us?&quot;},<br>	{ID: &quot;BS-4&quot;, Title: &quot;Order some food&quot;, Person: &quot;May&quot;, Information: &quot;Order some food for lunch.&quot;},<br>}</pre><pre>// getTasks responds with the list of all albums as JSON.<br>func getTasks(c *gin.Context) {<br>    c.IndentedJSON(http.StatusOK, tasks)<br>}</pre><pre><strong>// postTask<br>func postTask(c *gin.Context) {<br>    var newTask task</strong></pre><pre><strong>    // Call BindJSON to bind the received JSON to newTask.<br>    if err := c.BindJSON(&amp;newTask); err != nil {<br>        return<br>    }</strong></pre><pre><strong>    // Add the new album to the slice.<br>    tasks = append(tasks, newTask)<br>    c.IndentedJSON(http.StatusCreated, newTask)<br>}</strong></pre><pre>func main() {<br>    router := gin.Default()<br>    router.GET(&quot;/tasks&quot;, getTasks)<br>   <strong> router.POST(&quot;/tasks&quot;, postTasks)</strong></pre><pre>    router.Run(&quot;localhost:8080&quot;)<br>}</pre><p>Context.BindJSON bind he request body to newTask. Also, 201 status code add to the response.</p><pre>// terminal<br>$ <strong>curl &lt;http://localhost:8080/tasks&gt; \\                                                                                                                         <br>	    --include \\<br>	    --header &quot;Content-Type: application/json&quot; \\<br>	    --request &quot;POST&quot; \\<br>	    --data &#39;{&quot;id&quot;: &quot;BS-5&quot;,&quot;title&quot;: &quot;POST request&quot;,&quot;person&quot;:</strong> &quot;kuzey&quot;,&quot;information&quot;: &quot;create a tasks in post request&quot; }&#39;<br>HTTP/1.1 201 Created<br>Content-Type: application/json; charset=utf-8<br>Date: Thu, 30 Dec 2021 19:48:34 GMT<br>Content-Length: 72</pre><pre>$ <strong>curl &lt;http://localhost:8080/tasks&gt;</strong><br>[<br>    {<br>        &quot;id&quot;: &quot;BS-1&quot;,<br>        &quot;title&quot;: &quot;Create an API&quot;,<br>        &quot;person&quot;: &quot;Kuzey&quot;,<br>        &quot;information&quot;: &quot;Create a simple task api that people create some tasks and reach all of the task.&quot;<br>    },<br>    {<br>        &quot;id&quot;: &quot;BS-2&quot;,<br>        &quot;title&quot;: &quot;Write a blog&quot;,<br>        &quot;person&quot;: &quot;Kuzey&quot;,<br>        &quot;information&quot;: &quot;Write a blog that people who interested in Go can write create their API.&quot;<br>    },<br>    {<br>        &quot;id&quot;: &quot;BS-3&quot;,<br>        &quot;title&quot;: &quot;Make a coffe for us&quot;,<br>        &quot;person&quot;: &quot;John&quot;,<br>        &quot;information&quot;: &quot;29.12.2021 we have a coffe talk session. Can we make a coffe for us?&quot;<br>    },<br>    {<br>        &quot;id&quot;: &quot;BS-4&quot;,<br>        &quot;title&quot;: &quot;Order some food&quot;,<br>        &quot;person&quot;: &quot;May&quot;,<br>        &quot;information&quot;: &quot;Order some food for lunch.&quot;<br>    },<br>    {<br>        &quot;id&quot;: &quot;BS-5&quot;,<br>        &quot;title&quot;: &quot;POST request&quot;,<br>        &quot;person&quot;: &quot;kuzey&quot;,<br>        &quot;information&quot;: &quot;create a tasks in post request&quot;<br>    }<br>]%</pre><p>Sometime, we want to reach specific item. In this function, we will create a GET request with specific id. Let’s say function name is getTaskByID.</p><pre>// main.go<br>package main</pre><pre>import (<br>    &quot;net/http&quot;</pre><pre>    &quot;github.com/gin-gonic/gin&quot;<br>)</pre><pre>type task struct { <br>	ID          string `json:&quot;id&quot;` // we will use json so we need specify what a field’s name should be<br>	Title       string `json:&quot;title&quot;`<br>	Person      string `json:&quot;artist&quot;`<br>	Information string `json:&quot;information&quot;`<br>}</pre><pre>// Also we can create a simple data. In real life, the data come // from database.<br>// In here, we will store data in localy.<br>var tasks = []task{<br>	{ID: &quot;BS-1&quot;, Title: &quot;Create an API&quot;, Person: &quot;Kuzey&quot;,   Information: &quot;Create a simple task api that people create some tasks and reach all of the task.&quot;},<br>	{ID: &quot;BS-2&quot;, Title: &quot;Write a blog&quot;, Person: &quot;Kuzey&quot;, Information: &quot;Write a blog that people who interested in Go can write create their API.&quot;},<br>	{ID: &quot;BS-3&quot;, Title: &quot;Make a coffe for us&quot;, Person: &quot;John&quot;, Information: &quot;29.12.2021 we have a coffe talk session. Can we make a coffe for us?&quot;},<br>	{ID: &quot;BS-4&quot;, Title: &quot;Order some food&quot;, Person: &quot;May&quot;, Information: &quot;Order some food for lunch.&quot;},<br>}</pre><pre>// getTasks responds with the list of all albums as JSON.<br>func getTasks(c *gin.Context) {<br>    c.IndentedJSON(http.StatusOK, tasks)<br>}</pre><pre>// postTask<br>func postTask(c *gin.Context) {<br>    var newTask task</pre><pre>    // Call BindJSON to bind the received JSON to newTask.<br>    if err := c.BindJSON(&amp;newTask); err != nil {<br>        return<br>    }</pre><pre>    // Add the new album to the slice.<br>    tasks = append(tasks, newTask)<br>    c.IndentedJSON(http.StatusCreated, newTask)<br>}</pre><pre><strong>// get task by Id<br>func getTaskByID(c *gin.Context) {<br>    id := c.Param(&quot;id&quot;)<br>		println(id)<br>    // Loop over the list of tasks, looking for<br>    // an album whose ID value matches the parameter.<br>    for _, a := range tasks {<br>        if a.ID == id {<br>            c.IndentedJSON(http.StatusOK, a)<br>            return<br>        }<br>    }<br>    c.IndentedJSON(http.StatusNotFound, gin.H{&quot;message&quot;: &quot;task not found&quot;})<br>}</strong></pre><pre>func main() {<br>    router := gin.Default()<br>    router.GET(&quot;/tasks&quot;, getTasks)<br>    router.POST(&quot;/tasks&quot;, postTask)<br>    <strong>router.GET(&quot;/tasks/:id&quot;, getTaskByID)</strong></pre><pre>    router.Run(&quot;localhost:8080&quot;)<br>}</pre><p>Context.Param retrieved the id path parameter from the URL. When you map this handler to a path, you’ll include a placeholder for the parameter in the path. http.StatisNotFound returns the HTTP 404.</p><pre>// terminal<br>$ go run .<br>$ curl &lt;http://localhost:8080/tasks/BS-2&gt;<br>{<br>    &quot;id&quot;: &quot;BS-2&quot;,<br>    &quot;title&quot;: &quot;Write a blog&quot;,<br>    &quot;artist&quot;: &quot;Kuzey&quot;,<br>    &quot;information&quot;: &quot;Write a blog that people who interested in Go can write create their API.&quot;<br>}%</pre><pre>$ curl &lt;http://localhost:8080/tasks/BS-6&gt;<br>{<br>    &quot;message&quot;: &quot;task not found&quot;<br>}%</pre><p>This blog post is personal notes 🙂 If you are more interested in it, you need to check <a href="https://go.dev/doc/tutorial/web-service-gin">https://go.dev/doc/tutorial/web-service-gin</a> site.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80abb49a226c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Go from documentation #5 (Last Create a module blog)]]></title>
            <link>https://kuzeykose.medium.com/learning-go-from-documentation-5-last-create-a-module-blog-192d90d027f9?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/192d90d027f9</guid>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Sun, 26 Dec 2021 20:02:06 GMT</pubDate>
            <atom:updated>2021-12-26T20:02:06.764Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xImNR5VWRBR6jVYsBC-QfA.jpeg" /></figure><h3>Blog #4 Continues</h3><p>This blog is the last ‘Learning Go From documentation’ blog. In these 5 blogs, I tried to take some personal notes. So, If you are more interested, you need to check the official go documentation page. Right now, we will continue our code by greeting multiple people and adding a test. Let’s start with changing the greetings.go file to welcoming multiple people.</p><p>In blog #4, we edited the greetings.go file for selecting a random greeting. Now, handling multiple names is our task. So, we need to change greetings.go file first. Hellos function is new function to handle it. It returning parameters is little bit strange <strong>(map[string]string, error)</strong>. This means that Hellos functions returns array of string.</p><blockquote><em>Create a </em><em>messages map to associate each of the received names (as a key) with a generated message (as a value). In Go, you initialize a map with the following syntax: </em><em>make(map[*key-type*]*value-type*). You have the </em><em>Hellos function return this map to the caller. For more about maps, see </em><a href="https://blog.golang.org/maps"><em>Go maps in action</em></a><em> on the Go blog.</em></blockquote><p>Also, Determine the <strong>messages</strong> variable for assigned values. Then, we need to loop through the names with for loop and call the Hello function for each name.</p><pre>// greatings.go<br>package greetings</pre><pre>import (<br>	&quot;errors&quot;<br>	&quot;fmt&quot;<br>	&quot;math/rand&quot;<br>	&quot;time&quot;<br>)</pre><pre>func Hello(name string) (string, error) {<br>	if name == &quot;&quot; {<br>		return name, errors.New(&quot;empty name&quot;)<br>	}<br>	message := fmt.Sprintf(randomFormat(), name)<br>	return message, nil<br>}</pre><pre>// Hellos returns a map that associates each of the named people<br>// with a greeting message.<br>func Hellos(names []string) (map[string]string, error) {<br>	// A map to associate names with messages.<br>	messages := make(map[string]string)<br>	// Loop through the received slice of names, calling<br>	// the Hello function to get a message for each name.<br>	for _, name := range names {<br>		message, err := Hello(name)<br>		if err != nil {<br>			return nil, err<br>		}<br>		// In the map, associate the retrieved message with<br>		// the name.<br>		messages[name] = message<br>	}<br>	return messages, nil<br>}</pre><pre>func init() {<br>	rand.Seed(time.Now().UnixNano())<br>}</pre><pre>func randomFormat() string {<br>	formats := []string{<br>		&quot;Hi, %v. Welcome!&quot;,<br>		&quot;Great to see you, %v!&quot;,<br>		&quot;Hail, %v! Well met!&quot;,<br>	}</pre><pre>	return formats[rand.Intn(len(formats))]<br>}</pre><p>Let’s turn back to hello folder inside hello.go file. Now we have a opportunity that give a multiple names in Hellos function.</p><pre>// hello.go<br>package main</pre><pre>import (<br>    &quot;fmt&quot;<br>    &quot;log&quot;</pre><pre>    &quot;example.com/greetings&quot;<br>)</pre><pre>func main() {<br>    log.SetPrefix(&quot;greetings: &quot;)<br>    log.SetFlags(0)</pre><pre>    // A slice of names.<br>    names := []string{&quot;Gladys&quot;, &quot;Samantha&quot;, &quot;Darrin&quot;}</pre><pre>    messages, err := greetings.Hellos(names)<br>    if err != nil {<br>        log.Fatal(err)<br>    }<br>    <br>		fmt.Println(messages)<br>}</pre><p>Our names slice which is multiple names as an array of string (slice). These names are go inside the Hellos function and return a greetings for each. Run the function.</p><pre>// terminal<br>$ go run .<br>map[Darrin:Hail, Darrin! Well met! Gladys:Hail, Gladys! Well met! Samantha:Hail, Samantha! Well met!]</pre><h3>Testing</h3><p>So, last but not least TESTING! Go supports unit testing for easier to test as you go. Let’s turn the greeting folder and create a new file greetings_test.go.</p><blockquote><em>Ending a file’s name with _test.go tells the </em><em>go test command that this file contains test functions.</em></blockquote><pre>// greeting_test.go<br>package greetings</pre><pre>import (<br>    &quot;testing&quot;<br>    &quot;regexp&quot;<br>)</pre><pre>// TestHelloName calls greetings.Hello with a name, checking<br>// for a valid return value.<br>func TestHelloName(t *testing.T) {<br>    name := &quot;Gladys&quot;<br>    want := regexp.MustCompile(`\\b`+name+`\\b`)<br>    msg, err := Hello(&quot;Gladys&quot;)<br>    if !want.MatchString(msg) || err != nil {<br>        t.Fatalf(`Hello(&quot;Gladys&quot;) = %q, %v, want match for %#q, nil`, msg, err, want)<br>    }<br>}</pre><pre>// TestHelloEmpty calls greetings.Hello with an empty string,<br>// checking for an error.<br>func TestHelloEmpty(t *testing.T) {<br>    msg, err := Hello(&quot;&quot;)<br>    if msg != &quot;&quot; || err == nil {<br>        t.Fatalf(`Hello(&quot;&quot;) = %q, %v, want &quot;&quot;, error`, msg, err)<br>    }<br>}</pre><p>In this code, we added test package. Then, we create two test function to test the greetings.Hello function.</p><blockquote><em>Test function names have the form </em><em>Test*Name*, where </em>Name<em> says something about the specific test. Also, test functions take a pointer to the </em><em>testing package&#39;s </em><em>[testing.T type](</em><a href="https://pkg.go.dev/testing/#T"><em>https://pkg.go.dev/testing/#T</em></a><em>) as a parameter. You use this parameter&#39;s methods for reporting and logging from your test.</em></blockquote><p>Run the code;</p><pre>// terminal<br>$ go test<br>PASS<br>ok  	example.com/greetings	0.212s</pre><pre>$ go test -v<br>=== RUN   TestHelloName<br>--- PASS: TestHelloName (0.00s)<br>=== RUN   TestHelloEmpty<br>--- PASS: TestHelloEmpty (0.00s)<br>PASS<br>ok  	example.com/greetings	0.103s</pre><p>This blog post is personal notes 🙂 If you are more interested in it, you need to check <a href="https://go.dev/doc/tutorial/greetings-multiple-people">https://go.dev/doc/tutorial/greetings-multiple-people</a>, <a href="https://go.dev/doc/tutorial/add-a-test">https://go.dev/doc/tutorial/add-a-test</a> site.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=192d90d027f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Go from Documentation #4 (Return a random greeting)]]></title>
            <link>https://kuzeykose.medium.com/learning-go-from-documentation-4-return-a-random-greeting-4b7a91ce4c2f?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/4b7a91ce4c2f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming-languages]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 18:01:18 GMT</pubDate>
            <atom:updated>2021-12-24T18:01:18.277Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aTwZq7ceSHClNuAconBNig.jpeg" /></figure><p>In this blog, we will learn how to use Go slice. This is 4th blog which continues with documentation. We will use folders that we created at <a href="https://kuzeykose.medium.com/learning-go-from-documentation-3-error-handling-70a70764b83a">#3 blog</a>. Let’s start.</p><p>Firstly open the greetings folder, then greetings.go file. Starting a small slice to learning how it works is our target. Let’s create a three greeting messages and return one of the messages randomly. Also, we need to <strong>math/rand</strong> and <strong>time</strong> package.</p><pre>package greetings</pre><pre>import (<br>	&quot;errors&quot;<br>	&quot;fmt&quot;<br>	&quot;math/rand&quot;<br>	&quot;time&quot;<br>)</pre><pre>func Hello(name string) (string, error) {<br>	if name == &quot;&quot; {<br>			return name, errors.New(&quot;empty name&quot;)<br>	}<br>	// Create a message using a random format.<br>	message := fmt.Sprintf(randomFormat(), name)<br>	return message, nil<br>}</pre><pre>// init sets initial values for variables used in the function.<br>func init() {<br>	rand.Seed(time.Now().UnixNano())<br>}</pre><pre>// randomFormat returns one of a set of greeting messages. The returned<br>// message is selected at random.<br>func randomFormat() string {<br>	formats := []string{<br>			&quot;Hi, %v. Welcome!&quot;,<br>			&quot;Great to see you, %v!&quot;,<br>			&quot;Hail, %v! Well met!&quot;,<br>	}</pre><pre>	// Return a randomly selected message format by specifying<br>	// a random index for the slice of formats.<br>	return formats[rand.Intn(len(formats))]<br>}</pre><blockquote><em>Go executes init functions automatically at program startup, after global variables have been initialized.</em></blockquote><p>We added a <strong>randomFormat</strong> function. This function selects randomly a format in formats slices. Math/rand package used for generating a random number with rand. Besides, the init function seeds the rand package with the current time.</p><blockquote><strong><em>Array</em></strong><em>: An array’s length is part of its type, so arrays cannot be resized.</em></blockquote><blockquote><strong><em>Slices:</em></strong><em> An array has a fixed size. A slice, on the other hand, is a dynamically-sized, flexible view into the elements of an array. In practice, slices are much more common than arrays.</em></blockquote><p>We have done the greeting.go file. Let’s continue with the Hello folder. This file doesn’t have any changes. Because our greeting.go is manage our <strong>greeting.Hello</strong> function. In the Error handling blog, we removed the string in <strong>greetings.Hello</strong>. Now, we will add “Kuzey”.</p><pre>// hello.go<br>package main</pre><pre>import (<br>    &quot;fmt&quot;<br>    &quot;log&quot;</pre><pre>    &quot;example.com/greetings&quot;<br>)</pre><pre>func main() {<br>    log.SetPrefix(&quot;greetings: &quot;)<br>    log.SetFlags(0)</pre><pre>    // Request a greeting message.<br>    message, err := greetings.Hello(&quot;Kuzey&quot;) <br>    if err != nil {<br>        log.Fatal(err)<br>    }</pre><pre>    fmt.Println(message)<br>}</pre><p>Then, run the code multiple times the see a randomly selected greeting.</p><pre>// terminal<br>// cd -hello folder</pre><pre>$ go run .<br>Hi, Kuzey. Welcome!<br>$ go run .<br>Hi, Kuzey. Welcome!<br>$ go run .<br>Hail, Kuzey! Well met!</pre><p>This blog post is personal notes 🙂 If you are more interested in it, you need to check <a href="https://go.dev/doc/tutorial/random-greeting">https://go.dev/doc/tutorial/random-greeting</a> site.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4b7a91ce4c2f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Go from Documentation #3 (Error handling)]]></title>
            <link>https://kuzeykose.medium.com/learning-go-from-documentation-3-error-handling-70a70764b83a?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/70a70764b83a</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Fri, 24 Dec 2021 04:02:49 GMT</pubDate>
            <atom:updated>2021-12-24T04:02:49.723Z</atom:updated>
            <content:encoded><![CDATA[<p>This blog is about returning and handling an error. Handling errors is an essential topic. We created two simple modules in <a href="https://kuzeykose.medium.com/learning-go-from-documentation-2-call-your-code-from-another-module-3cdcc7629e72?source=your_stories_page----------------------------------------"><strong>Learning Go from Documentation #2 (Call your code from another module)</strong></a>. We are continuing with a created folder in the #2 blog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7XXPlFt1TdXDlmAr7HMnA.jpeg" /></figure><p>We have a greetings folder. Inside of this folder, we have a greeting.go file. We need to change the greetings.go file.</p><pre>// greetings.go<br>package greetings</pre><pre>import (<br>    &quot;errors&quot;<br>    &quot;fmt&quot;<br>)</pre><pre>// Hello returns a greeting for the named person.<br>func Hello(name string) (string, error) {<br>    // If no name was given, return an error with a message.<br>    if name == &quot;&quot; {<br>        return &quot;&quot;, errors.New(&quot;empty name&quot;)<br>    }</pre><pre>    // If a name was received, return a value that embeds the name<br>    // in a greeting message.<br>    message := fmt.Sprintf(&quot;Hi, %v. Welcome!&quot;, name)<br>    return message, nil<br>}</pre><p>Importing errors package is essential here. This is because errors can be usable like <strong>errors.New(”empty name”)</strong>. In the Hello function, the control of the name is provided is empty or not. Then return empty string and error. Your caller will check the second value to see if an error occurred. Also, adding nil (meaning no error) to the second return shows a successful return.</p><blockquote><em>Any Go function can return multiple values.</em></blockquote><p>Let’s move on to the hello folder, hello.go file. Now, we handle the error that returns by the Hello function.</p><pre>// hello.go<br>package main</pre><pre>import (<br>    &quot;fmt&quot;<br>    &quot;log&quot;</pre><pre>    &quot;example.com/greetings&quot;<br>)</pre><pre>func main() {<br>    log.SetPrefix(&quot;greetings: &quot;)<br>    log.SetFlags(0)</pre><pre>    message, err := greetings.Hello(&quot;&quot;)</pre><pre>		// error hendling<br>    if err != nil {<br>        log.Fatal(err)<br>    }</pre><pre>    fmt.Println(message)<br>}</pre><p>Configure the log package to print “greetings:” at the start with a log.SetPrefix(”greetings:”). Assign two returning parameters to <strong>message</strong> and <strong>err</strong>. For testing errors, let’s put the empty string in the Hello function. Then the condition part comes, if the error is not nil then log the error with <strong>log.Fatal(err)</strong>. If it’s nil, code continues with <strong>ftm.Println(message)</strong>.</p><p>Open the terminal and run what we write;</p><pre>// terminal</pre><pre>$ go run .<br>greetings: empty name<br>exit status 1</pre><p>This blog post is personal notes 🙂 If you are more interested in it, you need to check <a href="https://go.dev/doc/tutorial/handle-errors">https://go.dev/doc/tutorial/handle-errors</a> site.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=70a70764b83a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Go from Documentation #2 (Call your code from another module)]]></title>
            <link>https://kuzeykose.medium.com/learning-go-from-documentation-2-call-your-code-from-another-module-3cdcc7629e72?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/3cdcc7629e72</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Thu, 23 Dec 2021 04:02:43 GMT</pubDate>
            <atom:updated>2021-12-23T18:34:35.419Z</atom:updated>
            <content:encoded><![CDATA[<p>Creating simple module that can reachable another module is this blogs tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*81oVjlRcufPVKjZ2kuWXqg.jpeg" /></figure><blockquote><em>Go code is grouped into packages, and packages are grouped into modules.</em></blockquote><p>Let’s start with creating a Go module. Quickly, open the terminal (I use macOS), and write these commands. These create a folder and import a ‘go.mod’ file. You can reach all steps with <a href="https://kuzeykose.medium.com/learning-go-from-documentation-1-hello-world-3ae57b05f88?source=user_profile---------0-------------------------------">Learning Go from Documentation #1</a>.</p><pre>$ mkdir greetings<br>$ cd greetings<br>$ go mod init example.com/greetings<br>$ touch greetings.go</pre><p>then open this folder in any editor you like. I prefer <a href="https://code.visualstudio.com/">VSCode</a>. Select the greetings.go file and edit it with our first function.</p><pre>// greetings.go<br>package greetings</pre><pre>import &quot;fmt&quot;</pre><pre>func Hello(name string) string { <br>	message := fmt.Sprintf(&quot;Hi, %v. Welcome!&quot;, name)<br>	return message<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*ceeQ0SWN99XqOWwT.png" /></figure><p>Let’s talk about what we write. Describing functions is easy. func keyword identifies the function, then function name follows this keyword, in our function names is Hello. In parenthesis, functions take parameters and parameters type, and then return type follows these parentheses.</p><p>Also, we need to attention to the declaration operation <strong>:=</strong>, this is a shortcut for initializing a variable. In a long way, we need to use the<strong> var</strong> keyword. For example;</p><pre>var message string<br>message = ftm.Sprintf(&quot;Hi, %v. Welcom!&quot;, name)</pre><p>We import the <strong>ftm</strong> package using <strong>Sprintf</strong> function. Shortly, it changes %v to the name which comes from functions parameters, and returns manipulated string like “<strong>Hi, Kuzey. Welcome!</strong>”.</p><p>Let’s create another module and call our first function Hello. At the beginning of the blog, we create a folder and go files. We need to do it one more time but in a different folder.</p><pre>// terminal<br>$ cd ..<br>$ mkdir hello<br>$ cd hello<br>$ go mod init example.com/hello<br>$ touch hello.go</pre><p>then open the hello.go file and type down code like this. We learn what is function and what is declaration operator. So, easily we can understand this.</p><pre>// hello.go<br>package main</pre><pre>import (<br>    &quot;fmt&quot;</pre><pre>    &quot;example.com/greetings&quot;<br>)</pre><pre>func main() {<br>    message := greetings.Hello(&quot;Kuzey&quot;)<br>    fmt.Println(message)<br>}</pre><p>BUT! we have a little problem with “<a href="http://example.com/greetings"><strong>example.com/greetings</strong></a>”. This is because we don’t publish our package. If we are, Go tools could find it to download it. But our code is on our local file system. We need to describe where is the greeting package is in the local. “go mod edit” command helps us describe where it is.</p><pre>// terminal<br>$ go mod edit -replace example.com/greetings=../greetings<br>$ go mod tidy</pre><p>and run the go function!</p><pre>// terminal<br>$ go run .<br>Hi, Kuzey. Welcome!</pre><p>This blog post is personal notes 🙂 If you are more interested in it, you need to check, <a href="https://go.dev/doc/tutorial/create-module">https://go.dev/doc/tutorial/create-module</a>, <a href="https://go.dev/doc/tutorial/call-module-code">https://go.dev/doc/tutorial/call-module-code</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3cdcc7629e72" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Go from Documentation #1 (Hello, World!)]]></title>
            <link>https://kuzeykose.medium.com/learning-go-from-documentation-1-hello-world-3ae57b05f88?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ae57b05f88</guid>
            <category><![CDATA[go]]></category>
            <category><![CDATA[golang]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Wed, 22 Dec 2021 14:27:39 GMT</pubDate>
            <atom:updated>2021-12-23T06:04:17.083Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h4TLlisFk7XvtREAsS7C7Q.jpeg" /></figure><p>Installation is simple. Just download the package and install it. I haven’t got any experience on Windows and Linux, but you need to change PATH if you MacOS user. If you don’t, you will see ‘command not found: go’</p><pre>export PATH=$PATH:/usr/local/go/bin</pre><p>Let’s create a folder and initialize it with the init command which is ‘<strong>go mod init ‘example/hello</strong>’</p><pre>$ mkdir hello<br>$ cd hello<br>$ go mod init example/hello</pre><pre>$ touch hello.go</pre><p>go.mod file has to be created in this case. Let’s create a new go file to write some codes. ‘hello.go’ is our first file. Firstly, learning how to execute the function in go with “Hello, World!” function is essential.</p><pre>// in hello.go</pre><pre>package main // Declare a main package</pre><pre>import &quot;fmt&quot; //contains functions for formatting text</pre><pre>func main() {<br>	fmt.Println(&quot;Hello, World!&quot;)<br>}</pre><p>in terminal, run the command ‘<strong>go run</strong> .’, you are going to see Hello, World!.</p><p>Let’s try to add a new package our code. In <a href="https://pkg.go.dev/">pkg.go.dev</a>, we have opportunity to search some package. In documentation suggestions, let’s search a “quote”, and you need to find ‘<a href="http://rsc.io/quote%E2%80%99">rsc.io/quote’</a> package. Then turn back our code and implement it. Implementing is really easy.</p><pre>package main</pre><pre>import &quot;fmt&quot;</pre><pre>import &quot;rsc.io/quote&quot; // it has to be highlighted</pre><pre>func main() {<br>    fmt.Println(quote.Go())<br>}</pre><p>import “<a href="http://rsc.io/quote">rsc.io/quote</a>” has be highlighted because we don’t take the package yet. We need a go.sum file for use in authenticating the module. In terminal;</p><pre>$ go mod tidy<br>go: finding module for package rsc.io/quote<br>go: downloading rsc.io/quote v1.5.2<br>go: found rsc.io/quote in rsc.io/quote v1.5.2<br>go: downloading rsc.io/sampler v1.3.0<br>go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c</pre><p>the package will be installed and go.sum file created automatically. Let’s run the go function.</p><pre>$ go run .<br>Don&#39;t communicate by sharing memory, share memory by communicating.</pre><p>This blog post is personal notes 🙂 If you are more interested in it, you need to check <a href="https://go.dev/doc/tutorial/getting-started">https://go.dev/doc/tutorial/getting-started</a> site.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ae57b05f88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Learning Unity is fun!]]></title>
            <link>https://kuzeykose.medium.com/learning-unity-is-fun-cb27801bd4f9?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb27801bd4f9</guid>
            <category><![CDATA[unity]]></category>
            <category><![CDATA[unity-game-development]]></category>
            <category><![CDATA[game-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Mon, 20 Sep 2021 20:00:11 GMT</pubDate>
            <atom:updated>2021-09-20T20:00:11.980Z</atom:updated>
            <content:encoded><![CDATA[<p>I decided to learn Unity in a couple of months. So, I researched a lot, and I ran into the learn.unity.com website. Unity essentials tutorial is really fun. This tutorial just gives basic about what is 3d, how to use Unity etc. Then, I finished this tutorial and started another one which is a junior programming course. The first part was done and this is the first blog of my experience.</p><p>Creating a project is really easy. Junior Programming course starts with basic pieces of information. Directly starts to teach with how you work on Unity. In the first project, It gave a folder for those simple assets. Tutorial wants to import this folder to your prototype project. When the import part ends, you can learn how to use objects and materials inside Unity. For example, you can carry an object in the scene. In the asset folder, the basic environment imported also has an extra asset like vehicles.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/974/1*ci9qbZNif4e5qh6uApq4cA.png" /></figure><p>End of these, the coding part comes. I think the ‘Hello World’ project is moving object with code. Firstly, the tutorial teaches that creating a ‘scripts’ folder. All scripts will be created in this folder. When you right-click on the Project section, choose to create and choose C# Script. It is like;</p><pre>Create &#39;Scripts&#39; folder -&gt; go &#39;Scripts&#39; folder -&gt; right click -&gt; create -&gt; C# Script</pre><p>Initial code is writing automatically. Directly creates a public class with a name which is the file name. And also create two functions in this class. One of the functions is Start and another one is Update. You can see the code below.</p><pre>using System.Collections;<br>using System.Collections.Generic;<br>using UnityEngine;</pre><pre>public class PlayerController : MonoBehaviour {     <br>  // Start is called before the first frame update  <br>   <br>  void Start()<br>  {</pre><pre>  }<br>   <br>  // Update is called once per frame     <br>  void Update()     <br>  {             </pre><pre>  }<br> }</pre><p>Then the video series continues with moving some objects with coding. Actually, it is very easy. Unity thought everything for users. Some keywords help us to write some effective codes. In this example, we can use the ‘transform’ class. Inside the transform, the class Translate function helps us to move an object in a specific direction. When the save code and back to unity form ide. It is basic to apply this code to an object. Just drag and drop the Inspector tab.</p><pre>void Update() <br>{<br>   transform.Translate(Vector3.forward)        <br>}</pre><p>But this is so fast. We need to slow down so multiplication with (Time.deltaTime * 20) affects our speed.</p><pre>void Update() <br>{<br>   transform.Translate(Vector3.forward * Time.deltaTime * 20) <br>}</pre><p>Also, I added the Rigidbody component using add component button under the Inspector. This brings physics movements on the object like gravity. And the best time comes, press the play button 🙂 The vehicle directly starts to move straight and the main camera doesn’t follow the car. So, we need to add code to the camera.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FuQS84tOvviAeXMMrXyWJQ.png" /></figure><p>Let’s create another script file which name is ‘FollowPlayer’. Here, we need to think about how to camera follows the vehicle. The answer is, the vehicles and the position of the camera have to be close and they need to move together. Thus, getting the vehicle’s position and giving this position to the camera is part of a solution.</p><pre>// in FollowPlayer script<br>public GameObject player;<br>void Update() <br>{<br>  transform.potision = player.transform.position; <br>}</pre><p>When the FollowPlayer script integrates on the camera, the Player section automatically comes because, in code, we create a GameObject player. Then we need to change the car name with vehicle and drag-drop Player box. Now, the camera follows the vehicle because the positions are the same. We need to separate those two.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/451/1*cNLGQHZz401mrPO1QOMBUQ.png" /></figure><p>Open the FollowPlayer and add a new Vector3 for separating distance with vehicle and camera. And change the Update function name to LateUpdate for smoothness. Then let’s go to Unity and press the play button.</p><pre>// in FollowPlayer script <br>public GameObject player;<br>private Vector3 offset = new Vector3(0,5,-7);</pre><pre>void LateUpdate()<br>{<br>  transform.potision = player.transform.position + offset; <br>}</pre><p>We need to get data from the user to move this vehicle. Also, turning is a significant idea for a car. Let’s add these parts. In tutorial says that PlayerController needs more code for turning. Firstly open the PlayerController script and add the public float turnSpeed and using the transform.Translate() method with Vector3.right * Time.deltaTime * turnSpeed parameter.</p><pre>public float speed = 20;<br>public float turnSpeed;<br><br>void Update()<br>{<br>	transform.Translate(Vector3.forward * Time.deltaTime * speed);<br>	transform.Translate(Vector3.right * Time.deltaTime * turnSpeed);<br>}</pre><p>Then, the vehicle needs data from the user to move right and left. So, the program has to take input. Input.GetAxis(“Horizontal”) is a powerful method to take any action from the user. In this case, our left and right key is ‘a’ and ‘d’. You can change the horizontal input in Unity or in Code.</p><pre>public float speed = 20;<br>public float turnSpeed;<br>public float horizontalInput;</pre><pre>void Update()<br>{<br>	horizontalInput = Input.GetAxis(&quot;Horizontal&quot;);</pre><pre>	transform.Translate(Vector3.forward * Time.deltaTime * speed);<br>	transform.Translate(Vector3.right * Time.deltaTime * turnSpeed);<br>}</pre><p>Now, the vehicle can turn right and left but not looking good because only the x-axis changes the vehicle so can’t do rotating. Also, starting directly without pressing any button. We need to add some Vertical movement too. Let’s start with Vertical, it is the same as horizontal.</p><pre>public float speed = 20;<br>public float turnSpeed;<br>public float horizontalInput;<br>public float forwardInput;</pre><pre>void Update()<br>{<br>	horizontalInput = Input.GetAxis(&quot;Horizontal&quot;);<br>	forwardInput = Input.GetAxis(&quot;Vertical&quot;);</pre><pre>	transform.Translate(Vector3.forward * Time.deltaTime * speed * 	forwardInput);<br>	transform.Translate(Vector3.right * Time.deltaTime * turnSpeed);<br>}</pre><p>and secondly, change the <strong>transform.Translate(Vector3.right * Time.deltaTime * turnSpeed)</strong> to <strong>transform.Rotate</strong> function.</p><pre>public float speed = 20;<br>public float turnSpeed;<br>public float horizontalInput;<br>public float forwardInput;</pre><pre>void Update()<br>{<br>	horizontalInput = Input.GetAxis(&quot;Horizontal&quot;);<br>	forwardInput = Input.GetAxis(&quot;Vertical&quot;);</pre><pre>	transform.Translate(Vector3.forward * Time.deltaTime * speed * 	forwardInput);<br>	transform.Rotate(Vector3.up, Time.deltaTime * turnSpeed * horizontalInput);<br>}</pre><p>Refs</p><p><a href="https://learn.unity.com/pathway/junior-programmer">https://learn.unity.com/pathway/junior-programmer</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb27801bd4f9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using a Vim First Time - Cursor Movements]]></title>
            <link>https://kuzeykose.medium.com/using-a-vim-first-time-4ea0fcbf1f6d?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ea0fcbf1f6d</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[vim]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Sat, 14 Aug 2021 21:03:43 GMT</pubDate>
            <atom:updated>2021-08-16T05:59:44.348Z</atom:updated>
            <content:encoded><![CDATA[<p>I heard a Vim concept a lot. In few years, my friends praise some of its advantages such as using no more mouse. So, I don’t know why I didn’t try. Today! That’s the day to trying Vim. This blog is about my experience of trying How to use Vim (moving cursor). Also, I am currently using VSCode. There has a nice extension for Vim.</p><p>Firstly, I tried to do all steps without using a cheat sheet. Then, I decided that I made difficult it for the learning period.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wU7bTJEGJJzZrVCD-SVeKg.jpeg" /></figure><h3>Moving Around &amp; Editing Code</h3><p>The basic keys are moving with <strong>h</strong>,<strong>j</strong>,<strong>k</strong>,<strong>l</strong> characters. They work like pressing arrow keys.</p><ul><li>h -&gt; left</li><li>j -&gt; down</li><li>k -&gt; up</li><li>l -&gt; right</li></ul><p>Not complex right?</p><p>If you writing some code to your file. Using <strong>i</strong> character the set the insert mode. Then, you can get access to changing the file. When the editing is done, pressing <strong>ESC</strong> or <strong>ctrl+c</strong> keys to return back.</p><h3>Moving Fast</h3><p>If somewhere to take away your cursor fast on a line, then the <strong>w</strong> key helps you to jump from word to word. Also, <strong>ge</strong> keys are doing the same in opposite direction. just pressing <strong>e</strong> key will jump to the end of the word.</p><p>Using <strong>f{char}</strong> move the char directly in a line. For example, if you press <strong>f</strong> with <strong>t</strong> then Vim finds the next <strong>t</strong> in the line in front of the cursor. Character <strong>f</strong> is meaning like find. Using one time of <strong>f{char}</strong> is allow to using semicolumn to find the next char which pressed with f.</p><p>Sometimes, we want to turn back immediately with the first character of the line or end of the line. Vim has a key for all these.</p><ul><li><strong>0</strong> -&gt; Moves first character of the line</li><li><strong>^</strong> -&gt; Moves to the first non-blank character of a line</li><li><strong>$</strong> -&gt; Moves to the end of a line</li></ul><p>Moving is really important, also, moving fast is much more important. <strong>}</strong> jumps entire paragraphs downwards, <strong>{</strong> key upwards. <strong>ctrl+d</strong> moves you to down half a page, <strong>ctrl+u</strong> moves you to up half a page.</p><h3>Search Pattern</h3><p>Vim also allows you to search in a file in two ways.</p><ul><li><strong>/{pattern}</strong> to search forward inside a file</li><li><strong>?{pattern}</strong> to search backwards</li></ul><p>Also, you can use the <strong>*</strong> char the search pattern which the cursor is on.</p><h3>Other Moving Options</h3><p>Vim has much more skills for moving, but these are just enough for me. The last ones are a little bit cool.</p><ul><li><strong>gg</strong> goes to the top of the page</li><li><strong>{line}gg</strong> go directly the line like 45gg</li><li><strong>G</strong> goes to the end of the file</li><li><strong>%</strong> jump to matching <strong>({[]})</strong></li></ul><p>— — — — — — — — — — — — — — — — — — — — — — —</p><p>Refs:</p><p><a href="https://vim.rtorr.com/">Vim Cheat Sheet</a></p><p><a href="https://github.com/VSCodeVim/Vim/blob/HEAD/ROADMAP.md">https://github.com/VSCodeVim/Vim/blob/HEAD/ROADMAP.md</a></p><p><a href="https://www.barbarianmeetscoding.com/blog/boost-your-coding-fu-with-vscode-and-vim">Boost Your Coding Fu With Visual Studio Code and Vim | Barbarian Meets Coding</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ea0fcbf1f6d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Increased My GPA 2.12 to 3.21?]]></title>
            <link>https://kuzeykose.medium.com/how-increased-my-gpa-2-12-to-3-21-3b74bfe934a5?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b74bfe934a5</guid>
            <category><![CDATA[students]]></category>
            <category><![CDATA[university]]></category>
            <category><![CDATA[work]]></category>
            <category><![CDATA[time-management]]></category>
            <category><![CDATA[study]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Tue, 13 Jul 2021 07:44:18 GMT</pubDate>
            <atom:updated>2021-07-13T13:16:09.984Z</atom:updated>
            <content:encoded><![CDATA[<p>When I started the university, my ideas were amazingly incredible. I thought I could work hard, do some projects, and double major. My English was not okay for getting lessons on English. I went to a prep school to improve. Then, my first years in university started in my department of electrical and electronics engineering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eJn9eEX7Lx8UCfRf2tgW0g.jpeg" /></figure><p>I studied strictly, for five or six months. My first midterms are fantastic as a result of studying. Day by day, I became lazy about my lessons. I traveled, watched tv series, hanged out with my friends a lot. Then, my grades decreased effects of these, because I didn’t want to study. My department was Electronics and electrical engineering but, I spend so much time programming. When the freshman year ends, my GPA of first-year is 2.12. I got some F and D but, my programming class was A. The second year didn’t something changing in my life. I started to earn some money for working in Pull&amp;Bear. Also, I read a lot of books in this less studying time about anything such as electronics, novels, programming, etc. When the second year ends, my GPA was 2.38. I increased by 0.26 with a bit of effort like working one day before the exam. Somewhere deep in my mind, I realized that I don’t want to live like this. I feel bad because I could do better than this. My hard-working skills are strong. I wanted to study, increasing my GPA, earn money on programming.</p><p>Second year’s summer, when the school ended. I worked on how to study and how to manage my time. I read some books about self-improvement on this topic such as Checklist Manifesto, Atomic Habits, and The 7 Habits of Highly Effective People. Then, day by day, I improved myself. Also, I studied programming in my free time. When the third year started, I wanted to ready for difficulties. I selected an extra two classes under semesters. Any my responsibility directly increased.</p><p>I started to study a lot. Because my goal was that trying to enhance my GPA upper than 3.00. In the first semester of the 3rd year, stress came directly because of responsibility. I never studied like that in 2 years. The first semester, I handled all these lessons but My GPA was not increased so much. My semester GPA was 3.02 but overall was 2.62. I needed to work much harden than this. I remember that my parents and my friends said that ‘You don’t have to work like this. You are so tired.’ But I set my goal. Then the second semester of the 3rd year, I challenged myself to get two more lessons with more credits. I got used to these studying hours. At the same time, I wanted to do something about computer science. I used ReactJs a year, I wanted to use it in school. I sent some emails to my professors about what should I do? Then, they give me a project about SmartPark. Afterward, this project was not talked about until the 4th year. When the third year ended, my semester GPA was 3,83 and my overall jumped to 2,95. I needed to continue this studying in the fourth year and I studied programming in the summer.</p><p>My fourth year continued with long study hours. My responsibility accrued with the final project. SmartPark project came into my life and my professors choose me as a researching assistant. Then, I earned some money while doing my final project. Also, the SmartPark project was based on ReactJs because I wanted to create like that. End of the first semester, my semester GPA was 3.72 and overall was 3.17. I achieved my goal exactly! Then my internship time came on the break. I did my internship at the RBS company, also, I am currently working here :). Then they offered me a part-time job while studying. I was really confused, but I didn’t want to miss this opportunity. And, I accepted! The coming semester waited for me with lots of difficulties. The worst experience was started when the semester started. I worked for a company, I studied my lessons and I worked for the school as a searching assistant. My working and studying time was above 13–14 hours. My semester GPA was decreased by 3.17 and overall was increased by 3.21. I graduated with a 3.21 GPA.</p><p>I’ve reached my goal! I got a full-time job offer. <br>We will see my next career life…</p><p>30 day blogging challenge #9</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b74bfe934a5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My First impression on VueJs — First Vue Experience]]></title>
            <link>https://kuzeykose.medium.com/my-first-impression-on-vuejs-first-vue-experience-4323a7720531?source=rss-a9c3c383ed69------2</link>
            <guid isPermaLink="false">https://medium.com/p/4323a7720531</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[vuejs]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Kuzey Köse]]></dc:creator>
            <pubDate>Sun, 11 Jul 2021 21:01:32 GMT</pubDate>
            <atom:updated>2021-07-11T21:01:32.546Z</atom:updated>
            <content:encoded><![CDATA[<h3>My First impression on VueJs</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OZh9rLHi2oD-d-hJkfipRA.jpeg" /></figure><p>I am a software engineer working on the front end. For a couple of years, I work with React on hobby projects. My professional experience started six or seven months ago. My front-end knowledge is increasing day by day, and I want to look at VueJs from a professional side.</p><h3>Installation</h3><p>When you open the Vues documentation, It is clear, easy to read, and understandable. Documentation welcomes the reader with What is Vue firstly. Also, there has a link under this introduction about the video course. I skipped all these parts, directly came to the installation part.</p><p>In the installation part, there has an NPM package to install Vue. You can directly use this command;</p><pre>$ npm install vue</pre><p>If you want a new project, you should visit the cli.vujs.org page to creating a project. The documentation on this side wants to run vue/cli. Then, you can check the version of the Vue.</p><pre>$ npm install -g @vue/cli<br>$ vue --version</pre><p>In Creating a Project side, ‘vue create’ helps us to create. Also, it asks questions like do you want to constitute a project Vue2 or Vue3, and do you want to use yarn or npm. In this scenario, I selected Vue2.</p><pre>$ vue create my-project</pre><p>After this, the Vue project has to be built on your machine. It says ‘cd my-project’ and ‘yarn serve’. You should get going inside the project on the terminal and starts the project.</p><pre>$ cd my-project<br>$ yarn serve</pre><p>Then, yarn runs directly on terminal. At that moment, on terminal you should see ‘App running at: …’</p><pre>DONE  Compiled successfully in 3218ms                                </pre><pre>App running at:<br>  - Local:   <a href="http://localhost:8080/">http://localhost:8080/</a><br>  - Network: <a href="http://192.168.0.11:8080/">http://192.168.0.11:8080/</a></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/880/1*lToFHUVVxqeWQ5Taa2dAlA.png" /></figure><p>Open your browser and go to the localhost page. And, Vue.js App salutes us. As you know, we did not touch some codes while doing these. Ope the code on VS code, atom, or what you use for a source code editor. I use the VS code, and I install the Vue extension. In that first look, folder management is basic and simple.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/257/1*0VIGFW7ddrO9EDWcVupa_A.png" /></figure><p>After this point, the main subject is starts. How to write some Vue code? :)</p><h3>Basic Vue</h3><p>When you check the created files, you can understand how to create a component and use it. Written files look likes HTML documents. In JSX, all files are javascript based (.js) and using HTML inside of the javascript. But, Vue is different from the JSX concept. It uses HTML-based template syntax which is using javascript inside of HTML. You can take much information on the document in the <a href="https://vuejs.org/v2/guide/syntax.html">Template Syntax</a> section.</p><h4>Interpolations</h4><p>Double curly braces are used for the basic form of data binding. In documentation says that it is “Mustache” syntax. The <em>name</em> is replaced with the value of the assigned value of <em>the name</em>.</p><pre>&lt;span&gt;Hello, {{ name }}&lt;/span&gt;</pre><p>The weird thing is Raw HTML. You can not use HTML inside the mustaches interprets. If you want to use another HTML in mustaches you have to use ‘v-html’. Also, using javascript is available in these mustaches.</p><pre>&lt;p&gt;Using mustaches: {{ <strong>rawHtml</strong> }}&lt;/p&gt; <br>&lt;p&gt;Using v-html directive: &lt;span v-html=&quot;<strong>rawHtml</strong>&quot;&gt;&lt;/span&gt;&lt;/p&gt;</pre><pre>{{ number + 1 }}<br>{{ message.split(&#39;&#39;).reverse().join(&#39;&#39;) }}</pre><h4>Directives</h4><p>Directives can usable with the <strong>v- </strong>prefix. These are special attributes. The documentation says that ‘Directive attribute values are expected to be a single JavaScript expression. A directive’s job is to reactively apply side effects to the DOM when the value of its expression changes. Let’s review the example we saw in the introduction’. I think this concept can be learnable with practice.</p><pre>&lt;p <strong>v-if</strong>=&quot;seen&quot;&gt;Now you see me&lt;/p&gt;<br>&lt;a <strong>v-bind</strong>:href=&quot;url&quot;&gt; ... &lt;/a&gt;<br>&lt;a <strong>v-on</strong>:click=&quot;doSomething&quot;&gt; ... &lt;/a&gt;</pre><p>Also, modifiers exists for easy to use. These are special postfixes denoted by a dot. For example, it looks like event.preventDefault() but simpler version, <strong>.prevent</strong> modifier on <strong>v-on</strong>.</p><pre>&lt;form <strong>v-on:submit.prevent</strong>=&quot;onSubmit&quot;&gt; ... &lt;/form&gt;</pre><p>So, today we are installed Vue and take a quick tour of basic codes. And, notes are taken. In the documentation, I read these parts;</p><ul><li>Installation</li><li>Introduction</li><li>The Vue Instance</li><li>Template Syntax</li></ul><p>I suggest you read all of these in documentation if you don’t read. Because reading docs is a good skill for everybody. My Vue notes will be continued…</p><p>30 day blogging challenge #8</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4323a7720531" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>