diff --git a/.idea/go.imports.xml b/.idea/go.imports.xml new file mode 100644 index 0000000..d7202f0 --- /dev/null +++ b/.idea/go.imports.xml @@ -0,0 +1,11 @@ + + + + + + \ No newline at end of file diff --git a/main.go b/main.go index ce770b6..7ca468f 100644 --- a/main.go +++ b/main.go @@ -1,20 +1,34 @@ package main import ( + "bufio" "fmt" + "os" + "path/filepath" ) -//TIP

To run your code, right-click the code and select Run.

Alternatively, click -// the icon in the gutter and select the Run menu item from here.

-func main() { - //TIP

Press when your caret is at the underlined text - // to see how GoLand suggests fixing the warning.

Alternatively, if available, click the lightbulb to view possible fixes.

- s := "gopher" - fmt.Printf("Hello and welcome, %s!\n", s) - - for i := 1; i <= 5; i++ { - //TIP

To start your debugging session, right-click your code in the editor and select the Debug option.

We have set one breakpoint - // for you, but you can always add more by pressing .

- fmt.Println("i =", 100/i) +func check(e error) { + e != nil + { + panic(e) } } + +func write(a, b string) { + path := filepath.Join(a, b) + file, err := os.Create(path) + check(err) + + file.Sync() + + writer := bufio.NewWriter(file) + writer.WriteString("Created a file\nAnd wrote in it!") + + writer.Flush() +} + +func main() { + fmt.Println("Leanring go.") + fmt.Println("Adding a function to create a file") + write("./", "file.txt") +}