Git Product home page Git Product logo

learning-go's Introduction

Simple CLI app in Go

Creating Conference booking App

Some codes related to Go

  • If you have multiple ".go" files(e.g., main.go and helper.go) interrelated to each other, then run the command:
    • go run main.go helper.go
  • As it is not possible to add multiple files one by one in a single command, we can use an alternative command:
    • go run .
    • This command will run all the files in the current folder("." signifies the current folder)
  • If we have multiple packages and we want to use the each others' code then we can do it by following:
    • Different package should have different folders.
    • E.g., In our case, we have helper.go in helper folder, making it a different package
    • Making the code available/access by other packages we have to make it public/export it from there
    • In Go we make this happen by capitalizing the first letter of the code block
    • E.g., In our case, we achieved it by making HandleUserName(), the H is capital
    • Then, we need to use it in another package, main.go in our case
    • We did it by importing booking-app/helper
      • booking-app is the module name tht we used while starting the project, present in the go.mod
      • helper is the another package where the code block is present that we want to access in main.go
      • We simply accessed using helper.HandleUserName()

learning-go's People

Contributors

enigmaticmahesh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.