This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load("@bazel_gazelle//:def.bzl", "gazelle") | |
| # gazelle:prefix github.com/shubhag/bazel-golang-hello-world | |
| gazelle(name = "gazelle") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") | |
| http_archive( | |
| name = "io_bazel_rules_go", | |
| sha256 = "2b1641428dff9018f9e85c0384f03ec6c10660d935b750e3fa1492a281a53b0f", | |
| urls = [ | |
| "https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", | |
| "https://github.com/bazelbuild/rules_go/releases/download/v0.29.0/rules_go-v0.29.0.zip", | |
| ], | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func main() { | |
| fmt.Println("Hello world") | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package main | |
| import ( | |
| "bytes" | |
| "encoding/json" | |
| "io" | |
| "os" | |
| "os/exec" | |
| "time" | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type customWriter struct { | |
| w io.Writer | |
| } | |
| func (e customWriter) Write(p []byte) (int, error) { | |
| n, err := e.w.Write(p) | |
| if err != nil { | |
| return n, err | |
| } | |
| if n != len(p) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type customWriter struct { | |
| } | |
| func (e customWriter) Write(p []byte) (int, error) { | |
| // implement the functionality | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type line struct { | |
| Message string | |
| Timestamp time.Time | |
| Severity string | |
| } | |
| type customWriter struct { | |
| w io.Writer | |
| severity string | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // This method execute a command in a sub-process and outputs the generated logs to a file. | |
| func run(f *os.File) error { | |
| args := []string{"-c", `echo "Standard output message"; >&2 echo "Standard error message"`} | |
| cmd := exec.Command("bash", args...) | |
| cmd.Stdout = f | |
| cmd.Stderr = f | |
| return cmd.Run() | |
| } |