Compare commits

..

2 Commits
master ... dev

Author SHA1 Message Date
floraachy aa726ed1f6 ADD file via upload closed #1 2024-10-19 09:29:26 +08:00
floraachy 2409839e24 ADD file via upload closes #1 2024-10-19 09:28:48 +08:00
6 changed files with 102 additions and 140 deletions

View File

@ -1,46 +0,0 @@
# Introduction
You don't need to compile from source in Developer mode, you can just use the [Chromebrew](https://github.com/skycocker/chromebrew)-provided version.
If your Chromebook is relatively new, you can enable the Linux VM now built into ChromeOS to install Go without developer mode. Follow the steps from the following Google Support article to enable this feature- https://support.google.com/chromebook/answer/9145439. This has been tested on a Samsung Chromebook Plus on version 71.0.3578.127. If this feature is not available for you, you will need to enable Developer Mode.
This tutorial will show you how to install, build, and run Go on Chrome OS.
Please note this has only been tested on a 64GB LTE Pixel, however it should work on other Chromebooks. Note that enabling developer mode reduces the security guarantees offered by Chrome OS.
# Install Go
First download the latest version of Go for Linux from the [Go Downloads page](https://go.dev/dl/).
After that, open a shell by hitting (CTRL+ALT+T) and typing in `shell` then hit enter. Then extract it using the following command (when replacing `< Go Linux package >` with the name of the file you downloaded):
```
sudo tar xpvf ~/Downloads/< Go Linux package > -C /usr/local
```
Go should now be installed you can test this by typing `/usr/local/go/bin/go`. If it installed correctly, you should see the Go help prompt. Go is now installed.
# Create a Workspace
To keep this simple just create a folder called `/usr/local/go/work`. Also, create a folder called `src` inside `/usr/local/go/work/`.
# Set PATH
Add the following to `~/.bashrc`:
```
export GOPATH="/usr/local/go/work"
export PATH="${PATH}:/usr/local/go/bin:${GOPATH}/bin"
```
This will allow you to run your Go programs in your shell.
# Test if it worked
First create a folder inside of your `/usr/local/go/src` folder. After that create a file in your folder called `hello.go` with the following in it:
```go
package main
import "fmt"
func main() {
fmt.Println("Hello, Chrome OS!")
}
```
Now, run `go install hello`. Then, run `${GOPATH}/bin/hello` (or just `hello` if you setup your GOPATH above) and you should see `Hello, Chrome OS!`.
***
# Reporting bugs
Please go to [Issues](https://github.com/golang/go/issues) to report any issues you have.

102
Errors.md Normal file
View File

@ -0,0 +1,102 @@
# Errors
Errors are indicated by returning an `error` as an additional return value from a function. A `nil` value means that there was no error.
` error `s can be turned into strings by calling `Error`, their only method. You can create an error from a string by calling `errors.New`:
```go
if failure {
return errors.New("inverse tachyon pulse failed")
}
```
or by using `fmt.Errorf`:
```go
if failure {
return fmt.Errorf("inverse tachyon pulse failed")
}
```
Error strings should not start with a capital letter because they'll often be prefixed before printing:
```go
err := TryInverseTachyonPulse()
if err != nil {
fmt.Printf("failed to solve problem: %s\n", err)
}
```
If you expect calling code to be able to handle an error, you can distinguish classes of errors either by returning special values, or new types. You only need to distinguish differences that the calling code could be expected to handle in this way as the string allows one to communicate the details of the error.
`io.EOF` is a special value that signals the end of a stream. You can compare error values directly against io.EOF.
If you want to carry extra data with the error, you can use a new type:
```go
type ParseError struct {
Line, Col int
}
func (p ParseError) Error() string {
return fmt.Sprintf("parse error on line %d, column %d", p.Line, p.Col)
}
```
If you want to create a constant string error, you can use a named type string:
```go
type errorConst string
const ErrTooManyErrors errorConst = "too many errors found."
func (e errorConst) Error() string {
return string(e)
}
```
Calling code would test for a special type of `error` by using a type switch:
```go
switch err := err.(type) {
case ParseError:
PrintParseError(err)
}
```
## Naming
Error types end in `"Error"` and error variables start with `"Err"` or `"err"`:
```go
package somepkg
// ParseError is type of error returned when there's a parsing problem.
type ParseError struct {
Line, Col int
}
var ErrBadAction = errors.New("somepkg: a bad action was performed")
// -----
package foo
func foo() {
res, err := somepkgAction()
if err != nil {
if err == somepkg.ErrBadAction {
}
if pe, ok := err.(*somepkg.ParseError); ok {
line, col := pe.Line, pe.Col
// ....
}
}
}
```
## References
* Errors (specification): https://go.dev/ref/spec#Errors
* Package `errors`: https://pkg.go.dev/errors/
* Type switches: https://go.dev/ref/spec#TypeSwitchStmt

View File

@ -1,2 +0,0 @@
# tesgsdfsgfd

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

View File

@ -1,92 +0,0 @@
{
"ID": "cs8voqbgnbnh5a7qt7vg",
"CreateUserID": 11,
"UpdateUserID": 0,
"CreatedAt": "2024-10-18T06:12:57Z",
"UpdatedAt": "2024-10-18T06:12:57Z",
"DeletedAt": null,
"WorkspaceID": "personal-11",
"Name": "测试",
"Description": "测试",
"Status": "Unpublished",
"RuntimeStatus": "Init",
"Icon": {
"Path": "upload/full/bc/e7/717c27048890f66a28fb3b02557e448ff8bab63836bcb2fe59d2840691b3",
"ID": "cs8voqbgnbnh5a7qt7v0",
"Sha256": "bce7717c27048890f66a28fb3b02557e448ff8bab63836bcb2fe59d2840691b3",
"Size": 78285
},
"Hash": "d5ce8c43d5c8d295695cf953ad0b5ae8",
"LastHash": "",
"Nodes": [
{
"ID": "cs8voqbgnbnh5a7qt800",
"CreateUserID": 11,
"UpdateUserID": 0,
"CreatedAt": "2024-10-18T06:12:57Z",
"UpdatedAt": "2024-10-18T06:12:57Z",
"DeletedAt": null,
"Type": "Start",
"Name": "Start",
"Layout": {
"X": 100,
"Y": 200
},
"StartConfig": {
"InputSchema": [
{
"Name": "",
"Required": true,
"Type": 0
}
],
"OutputSchema": [
{
"Name": "",
"Required": true,
"Type": 0
}
]
}
},
{
"ID": "cs8voqbgnbnh5a7qt80g",
"CreateUserID": 11,
"UpdateUserID": 0,
"CreatedAt": "2024-10-18T06:12:57Z",
"UpdatedAt": "2024-10-18T06:12:57Z",
"DeletedAt": null,
"Type": "End",
"Name": "End",
"Layout": {
"X": 1200,
"Y": 200
},
"EndConfig": {
"InputVariables": [
{
"Type": "",
"Name": "output",
"ValueFrom": {
"OutputRef": {
"NodeID": "",
"OutputFieldPath": ""
}
},
"StringValue": null,
"IntValue": null,
"DoubleValue": null,
"BoolValue": null
}
],
"OutputType": "",
"OutputSchema": [
{
"Name": "output",
"Type": -1
}
]
}
}
]
}