trynna fix nil

This commit is contained in:
bobbert committed 2026-07-15 20:20:08 +01:00
1 parent d3b4d45f4a
commit d5818cf669
2 files changed
+37 -12

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GoImports">
<option name="excludedPackages">
<array>
<option value="github.com/pkg/errors" />
<option value="golang.org/x/net/context" />
</array>
</option>
</component>
</project>
+26 -12
View File
@@ -1,20 +1,34 @@
package main
import (
"bufio"
"fmt"
"os"
"path/filepath"
)
//TIP <p>To run your code, right-click the code and select <b>Run</b>.</p> <p>Alternatively, click
// the <icon src="AllIcons.Actions.Execute"/> icon in the gutter and select the <b>Run</b> menu item from here.</p>
func main() {
//TIP <p>Press <shortcut actionId="ShowIntentionActions"/> when your caret is at the underlined text
// to see how GoLand suggests fixing the warning.</p><p>Alternatively, if available, click the lightbulb to view possible fixes.</p>
s := "gopher"
fmt.Printf("Hello and welcome, %s!\n", s)
for i := 1; i <= 5; i++ {
//TIP <p>To start your debugging session, right-click your code in the editor and select the Debug option.</p> <p>We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.</p>
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")
}