hello-world
This commit is contained in:
		
							parent
							
								
									79f77f009a
								
							
						
					
					
						commit
						2cb2de4caf
					
				
							
								
								
									
										35
									
								
								go/hello-world/.exercism/config.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								go/hello-world/.exercism/config.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,35 @@
 | 
			
		||||
{
 | 
			
		||||
  "authors": [
 | 
			
		||||
    "k4rtik"
 | 
			
		||||
  ],
 | 
			
		||||
  "contributors": [
 | 
			
		||||
    "bitfield",
 | 
			
		||||
    "ekingery",
 | 
			
		||||
    "ferhatelmas",
 | 
			
		||||
    "hilary",
 | 
			
		||||
    "kytrinyx",
 | 
			
		||||
    "leenipper",
 | 
			
		||||
    "petertseng",
 | 
			
		||||
    "robphoenix",
 | 
			
		||||
    "SebastianKristof",
 | 
			
		||||
    "sebito91",
 | 
			
		||||
    "tleen"
 | 
			
		||||
  ],
 | 
			
		||||
  "files": {
 | 
			
		||||
    "solution": [
 | 
			
		||||
      "hello_world.go"
 | 
			
		||||
    ],
 | 
			
		||||
    "test": [
 | 
			
		||||
      "hello_world_test.go"
 | 
			
		||||
    ],
 | 
			
		||||
    "example": [
 | 
			
		||||
      ".meta/example.go"
 | 
			
		||||
    ],
 | 
			
		||||
    "invalidator": [
 | 
			
		||||
      "go.mod"
 | 
			
		||||
    ]
 | 
			
		||||
  },
 | 
			
		||||
  "blurb": "The classical introductory exercise. Just say \"Hello, World!\".",
 | 
			
		||||
  "source": "This is an exercise to introduce users to using Exercism",
 | 
			
		||||
  "source_url": "https://en.wikipedia.org/wiki/%22Hello,_world!%22_program"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										1
									
								
								go/hello-world/.exercism/metadata.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								go/hello-world/.exercism/metadata.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
			
		||||
{"track":"go","exercise":"hello-world","id":"d4f5f27839e94f75a117c66838248852","url":"https://exercism.org/tracks/go/exercises/hello-world","handle":"negrienko","is_requester":true,"auto_approve":false}
 | 
			
		||||
							
								
								
									
										41
									
								
								go/hello-world/HELP.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								go/hello-world/HELP.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,41 @@
 | 
			
		||||
# Help
 | 
			
		||||
 | 
			
		||||
## Running the tests
 | 
			
		||||
 | 
			
		||||
To run the tests run the command `go test` from within the exercise directory.
 | 
			
		||||
 | 
			
		||||
If the test suite contains benchmarks, you can run these with the `--bench` and `--benchmem`
 | 
			
		||||
flags:
 | 
			
		||||
 | 
			
		||||
    go test -v --bench . --benchmem
 | 
			
		||||
 | 
			
		||||
Keep in mind that each reviewer will run benchmarks on a different machine, with
 | 
			
		||||
different specs, so the results from these benchmark tests may vary.
 | 
			
		||||
 | 
			
		||||
## Submitting your solution
 | 
			
		||||
 | 
			
		||||
You can submit your solution using the `exercism submit hello_world.go` command.
 | 
			
		||||
This command will upload your solution to the Exercism website and print the solution page's URL.
 | 
			
		||||
 | 
			
		||||
It's possible to submit an incomplete solution which allows you to:
 | 
			
		||||
 | 
			
		||||
- See how others have completed the exercise
 | 
			
		||||
- Request help from a mentor
 | 
			
		||||
 | 
			
		||||
## Need to get help?
 | 
			
		||||
 | 
			
		||||
If you'd like help solving the exercise, check the following pages:
 | 
			
		||||
 | 
			
		||||
- The [Go track's documentation](https://exercism.org/docs/tracks/go)
 | 
			
		||||
- The [Go track's programming category on the forum](https://forum.exercism.org/c/programming/go)
 | 
			
		||||
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
 | 
			
		||||
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
 | 
			
		||||
 | 
			
		||||
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
 | 
			
		||||
 | 
			
		||||
To get help if you're having trouble, you can use one of the following resources:
 | 
			
		||||
 | 
			
		||||
- [How to Write Go Code](https://golang.org/doc/code.html)
 | 
			
		||||
- [Effective Go](https://golang.org/doc/effective_go.html)
 | 
			
		||||
- [Go Resources](http://golang.org/help)
 | 
			
		||||
- [StackOverflow](http://stackoverflow.com/questions/tagged/go)
 | 
			
		||||
							
								
								
									
										45
									
								
								go/hello-world/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								go/hello-world/README.md
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,45 @@
 | 
			
		||||
# Hello World
 | 
			
		||||
 | 
			
		||||
Welcome to Hello World on Exercism's Go Track.
 | 
			
		||||
If you need help running the tests or submitting your code, check out `HELP.md`.
 | 
			
		||||
 | 
			
		||||
## Instructions
 | 
			
		||||
 | 
			
		||||
The classical introductory exercise.
 | 
			
		||||
Just say "Hello, World!".
 | 
			
		||||
 | 
			
		||||
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment.
 | 
			
		||||
 | 
			
		||||
The objectives are simple:
 | 
			
		||||
 | 
			
		||||
- Modify the provided code so that it produces the string "Hello, World!".
 | 
			
		||||
- Run the test suite and make sure that it succeeds.
 | 
			
		||||
- Submit your solution and check it at the website.
 | 
			
		||||
 | 
			
		||||
If everything goes well, you will be ready to fetch your first real exercise.
 | 
			
		||||
 | 
			
		||||
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
 | 
			
		||||
 | 
			
		||||
## Source
 | 
			
		||||
 | 
			
		||||
### Created by
 | 
			
		||||
 | 
			
		||||
- @k4rtik
 | 
			
		||||
 | 
			
		||||
### Contributed to by
 | 
			
		||||
 | 
			
		||||
- @bitfield
 | 
			
		||||
- @ekingery
 | 
			
		||||
- @ferhatelmas
 | 
			
		||||
- @hilary
 | 
			
		||||
- @kytrinyx
 | 
			
		||||
- @leenipper
 | 
			
		||||
- @petertseng
 | 
			
		||||
- @robphoenix
 | 
			
		||||
- @SebastianKristof
 | 
			
		||||
- @sebito91
 | 
			
		||||
- @tleen
 | 
			
		||||
 | 
			
		||||
### Based on
 | 
			
		||||
 | 
			
		||||
This is an exercise to introduce users to using Exercism - https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
 | 
			
		||||
							
								
								
									
										3
									
								
								go/hello-world/go.mod
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								go/hello-world/go.mod
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
			
		||||
module greeting
 | 
			
		||||
 | 
			
		||||
go 1.18
 | 
			
		||||
							
								
								
									
										6
									
								
								go/hello-world/hello_world.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								go/hello-world/hello_world.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
package greeting
 | 
			
		||||
 | 
			
		||||
// HelloWorld greets the world.
 | 
			
		||||
func HelloWorld() string {
 | 
			
		||||
	return "Hello, World!"
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										40
									
								
								go/hello-world/hello_world_test.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								go/hello-world/hello_world_test.go
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,40 @@
 | 
			
		||||
package greeting
 | 
			
		||||
 | 
			
		||||
import "testing"
 | 
			
		||||
 | 
			
		||||
// Define a function named HelloWorld that takes no arguments,
 | 
			
		||||
// and returns a string.
 | 
			
		||||
// In other words, define a function with the following signature:
 | 
			
		||||
// HelloWorld() string
 | 
			
		||||
 | 
			
		||||
func TestHelloWorld(t *testing.T) {
 | 
			
		||||
	expected := "Hello, World!"
 | 
			
		||||
	if observed := HelloWorld(); observed != expected {
 | 
			
		||||
		t.Fatalf("HelloWorld() = %v, want %v", observed, expected)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BenchmarkHelloWorld() is a benchmarking function. These functions follow the
 | 
			
		||||
// form `func BenchmarkXxx(*testing.B)` and can be used to test the performance
 | 
			
		||||
// of your implementation. They may not be present in every exercise, but when
 | 
			
		||||
// they are you can run them by including the `-bench` flag with the `go test`
 | 
			
		||||
// command, like so: `go test -v --bench . --benchmem`
 | 
			
		||||
//
 | 
			
		||||
// You will see output similar to the following:
 | 
			
		||||
//
 | 
			
		||||
// BenchmarkHelloWorld   	2000000000	         0.46 ns/op
 | 
			
		||||
//
 | 
			
		||||
// This means that the loop ran 2000000000 times at a speed of 0.46 ns per loop.
 | 
			
		||||
//
 | 
			
		||||
// While benchmarking can be useful to compare different iterations of the same
 | 
			
		||||
// exercise, keep in mind that others will run the same benchmarks on different
 | 
			
		||||
// machines, with different specs, so the results from these benchmark tests may
 | 
			
		||||
// vary.
 | 
			
		||||
func BenchmarkHelloWorld(b *testing.B) {
 | 
			
		||||
	if testing.Short() {
 | 
			
		||||
		b.Skip("skipping benchmark in short mode.")
 | 
			
		||||
	}
 | 
			
		||||
	for i := 0; i < b.N; i++ {
 | 
			
		||||
		HelloWorld()
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user