Giter Site home page Giter Site logo

go-projects's Introduction

GO-projects

The go mod init command creates a go.mod file to track your code's dependencies.

example : go mod init example.com/greetings

In Go, the := operator is a shortcut for declaring and initializing a variable in one line (Go uses the value on the right to determine the variable's type)

Edit the example.com/hello module to use your local example.com/greetings module

$ go mod edit -replace example.com/greetings=../greetings

run the go mod tidy command to synchronize the

go run . to run the main program

Error handling

if name == "" { return "", errors.New("empty name") }

if err != nil { log.Fatal(err) }

In Go, you initialize a map with the following syntax: make(map[key-type]value-type).

Ending a file's name with _test.go tells the go test command that this file contains test functions.

The go test command executes test functions (whose names begin with Test) in test files (whose names end with _test.go). You can add the -v flag to get verbose output that lists all of the tests and their results.

run the go build command to compile the code into an executable.

You've compiled the application into an executable so you can run it. But to run it currently, your prompt needs either to be in the executable's directory, or to specify the executable's path.

You can discover the install path by running the go list command, as in the following example:

$ go list -f '{{.Target}}'

Once you've updated the shell path, run the go install command to compile and install the package.

$ go install

go-projects's People

Contributors

prasri 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.