diff --git a/de/01.0.md b/de/01.0.md index a1e30140..7e7903fc 100644 --- a/de/01.0.md +++ b/de/01.0.md @@ -1,20 +1,21 @@ -# 1 Go Environment Configuration +# 1 Einrichtung der Go Entwicklungsumgebung -Welcome to the world of Go, let's start exploring! +Willkommen in der Welt von Go. Lass sie uns erforschen. -Go is a fast-compiled, garbage-collected, concurrent systems programming language. It has the following advantages: +Go ist eine schnell kompilierte, automatisch speicherbereinigte, multitaskingfähige Programmiersprache. Sie hat folgende Vorteile: -- Compiles a large project within a few seconds. -- Provides a software development model that is easy to reason about, avoiding most of the problems associated with C-style header files. -- Is a static language that does not have levels in its type system, so users do not need to spend much time dealing with relations between types. It is more like a lightweight object-oriented language. -- Performs garbage collection. It provides basic support for concurrency and communication. -- Designed for multi-core computers. +- Kompiliert große Projekte binnen Sekunden +- Bietet ein einfaches Model zur Softwareentwicklung, welches die meisten Probleme um C-ähnliche Probleme mit Header-Dateien vermeidet +- Sie ist eine statische Sprache ohne vielschichte Ebenen im Datentypensystem, sodass Benutzer nicht viel Zeit damit verschwenden, Verbindungen zwischen Datentypen herauszufinden. Es ist mehr wie eine leichtgewichtige, objekt-orientierte Programmiersprache. +- Führt eine automatische Speicherbereinigung (Garbage Collection) durch. Sie bietet grundlegende Unterstützung für das parallele Ausführen von Aufgaben und die Kommunikation zwischen diesen. +- Entworfen für Computer mit mehreren Rechnenkernen. -Go is a compiled language. It combines the development efficiency of interpreted or dynamic languages with the security of static languages. It is going to be the language of choice for modern, multi-core computers with networking. For these purposes, there are some problems that need to inherently be resolved at the level of the language of choice, such as a richly expressive lightweight type system, a native concurrency model, and strictly regulated garbage collection. For quite some time, no packages or tools have emerged that have aimed to solve all of these problems in a pragmatic fashion; thus was born the motivation for the Go language. -In this chapter, I will show you how to install and configure your own Go development environment. +Go ist eine kompilierte Sprache. Sie vereint während der Entwicklung die Effizienz von dynamischen Programmiersprachen mit der Sicherheit von statischen Sprachen. Sie ist die erste Wahl für moderne, mit Mehrkernprozessoren ausgestatten Computern, welche für die Netzwerkprogrammierung genutzt werden. Um diesen Anforderungen gerecht zu werden, müssen grundsätzliche Probleme in einer solchen Sprache gelöst werden. Dazu zählen ein ausdruckstarkes und zugleich leichtgewichtiges Datentypensystem, native Unterstützung zum simultanen Ausführen von Aufgaben und eine stark regulierte, automatische Speicherbereinigung. Eine lange Zeit gab es keine Packages oder andere Werkzeuge, mit dem Ziel, die genannten Probleme elegant zu lösen. Dies war letztendlich die Motivation, um Go zu entwicklen. + +In diesem Kapitel werde ich Dir zeigen, wie Du Deine eigene Go-Entwicklungsumgebung installierst und einrichtest. ## Links -- [Directory](preface.md) -- Next section: [Installation](01.1.md) +- [Inhaltsverzeichnis](preface.md) +- Nächster Abschnitt: [Installation](01.1.md) diff --git a/de/01.1.md b/de/01.1.md index eac6c9e7..4cd6fb45 100644 --- a/de/01.1.md +++ b/de/01.1.md @@ -1,108 +1,112 @@ # 1.1 Installation -## Three ways to install Go +## Drei Wege Go zu installieren -There are many ways to configure the Go development environment on your computer, and you can choose whichever one you like. The three most common ways are as follows. +Es gibt viele Wege, um eine Go-Entwicklungsumgebung auf Deinem Computer einzurichten und Du kannst die auswählen, welche Dir gefällt. Die Folgenden sind die drei Häufigsten: + +- Offizielle Installationspakete. + - Das Team um Go stellt praktische Installationspakete für Windows, Linux, Mac und andere Betriebssysteme zur Verfügung. Dies ist wahrscheinlich der einfachste Weg, um zu starten. +- Eingenhändige Kompilierung des Quellcodes. + - Beliebt untern Entwicklern, die mit UNIX-ähnlichen Systemen vertraut sind. +- Nutze Programme von Dritten. + - Da Draußen gibt es eine Menge Werkzeuge von Drittanbietern und Paketmanager, um Go zu installieren, wie apt-get in Ubuntu oder homebrew für Mac. -- Official installation packages. - - The Go team provides convenient installation packages in Windows, Linux, Mac and other operating systems. This is probably the easiest way to get started. -- Install it yourself from source code. - - Popular with developers who are familiar with Unix-like systems. -- Using third-party tools. - - There are many third-party tools and package managers for installing Go, like apt-get in Ubuntu and homebrew for Mac. - -In case you want to install more than one version of Go on a computer, you should take a look at a tool called [GVM](https://github.com/moovweb/gvm). It is the best tool I've seen so far for accomplishing this task, otherwise you'd have to deal with it yourself. +Im Fall, dass Du mehr als eine Version von Go auf Deinem Computer installieren möchtest, dann empfehle ich Dir, einen Blick auf [GVM](https://github.com/moovweb/gvm) zu werfen. Es ist die bisher beste Möglichkeit, die ich soweit gesehen habe, um dies zu tun. Andernfalls musst Du diese Aufgabe selbst bewältigen. -## Install from source code -Because some parts of Go are written in Plan 9 C and AT&T assembler, you have to install a C compiler before taking the next step. +## Eingenhändige Kompilierung des Quellcodes -On a Mac, if you have installed Xcode, you already have the compiler. +Da einige Bestandteile von Go in Plan 9 C und AT&T Assembler geschrieben sind, musst Du einen C-Compiler installieren, bevor Du den nächsten Schritt durchführst. -On Unix-like systems, you need to install gcc or a similar compiler. For example, using the package manager apt-get (included with Ubuntu), one can install the required compilers as follows: +Auf dem Mac, sofern Du Xcode installiert hast, ist bereits ein entsprechender Compiler vorhanden. - `sudo apt-get install gcc libc6-dev` -On Windows, you need to install MinGW in order to install gcc. Don't forget to configure your environment variables after the installation has completed.( ***Everything that looks like this means it's commented by a translator: If you are using 64-bit Windows, you should install the 64-bit version of MinGW*** ) +Auf UNIX-ähnlichen Systemen musst Du gcc oder einen vergleichbaren Compiler installieren. Zum Beispiel mit dem Paketmanager apt-get (welcher in Ubuntu integriert ist), kannst Du die benötigten Compiler wie folgt installieren: -At this point, execute the following commands to clone the Go source code and compile it.( ***It will clone the source code to your current directory. Switch your work path before you continue. This may take some time.*** ) +`sudo apt-get install gcc libc6-dev` + + +In Windows wird MinGW vorrausgesetzt, um folglich gcc zu installieren. Vergiss nicht, die Umgebungsvariablen nach der Installation zu konfigurieren. ( ***Alles was so aussieht wie dies, ist eine Anmerkung von den Übersetzern: Wenn Du eine 64-Bit Version von Windows nutzt, solltest Du auch eine 64-Bit Variante von MinGW installieren.*** ) + +Zu diesem Zeitpunkt, führe die folgenden Befehle aus, um Gos Quellcode zu "klonen" und zu kompilieren. ( ***Der Quellcode wird in Dein aktuelles Arbeitsverzeichnis "geklont". Wechsle dieses, bevor Du fortfährst. Es könnte eine Weile dauern.***) git clone https://go.googlesource.com/go cd go/src ./all.bash -A successful installation will end with the message "ALL TESTS PASSED." -On Windows, you can achieve the same by running `all.bat`. +Eine erfolgreiche Installation wird mit der Nachricht "ALL TESTS PASSED." beendet. -If you are using Windows, the installation package will set your environment variables automatically. In Unix-like systems, you need to set these variables manually as follows. ( ***If your Go version is greater than 1.0, you don't have to set $GOBIN, and it will automatically be related to your $GOROOT/bin, which we will talk about in the next section***) +In Windows kannst Du das Selbe erreichen, indem Du `all.bat` ausführst. + +Wenn Du Windows nutzt, richtet die Installationsroutine die Umgebungsvariablen automatisch ein. Auf UNIX-ähnlichen Systemen musst Du diese wie folgt manuell setzen. ( ***Nutzt Du Go 1.0 oder höher, dann brauchst Du $GOBIN nicht zu definieren, da diese Umgebungsvariable relativ zu $GOROOT/bin gesetzt wird, welche wir im nächsten Abschnitt behandeln werden.*** ) export GOROOT=$HOME/go export GOBIN=$GOROOT/bin export PATH=$PATH:$GOROOT/bin -If you see the following information on your screen, you're all set. +Wenn Du die folgenden Informationen auf Deinem Bildschirm siehst, ist alles erfolgreich verlaufen. ![](images/1.1.mac.png?raw=true) -Figure 1.1 Information after installing from source code +Abbildung 1.1 Informationen nach der manuellen Installation vom Quellcode -Once you see the usage information of Go, it means you have successfully installed Go on your computer. If it says "no such command", check that your $PATH environment variable contains the installation path of Go. +Sobald Du Informationen zur Nutzung von Go siehst, bedeutet dies, dass Du Go erfolgreich auf Deinem Computer installiert hast. Steht dort jedoch "no such command", überprüfe die $PATH Umgebungsvariable und schaue, ob Sie den Installationspfad von Go beinhaltet. -## Using the standard installation packages +## Nutze die offiziellen Installationspakete -Go has one-click installation packages for every supported operating system. These packages will install Go in `/usr/local/go` (`c:\Go` in Windows) by default. Of course this can be modified, but you also need to change all the environment variables manually as I've shown above. +Go bietet auch Ein-Klick-Installationspakete für jedes unterstützte Betriebssystem. Dieser Vorgang wird Go standardmäßig unter `/usr/local/go` (oder `C:\Go` unter Windows) installieren. Natürlich kannst Du dies nach belieben anpassen, jedoch musst Du die Umgebungsvariablen wie oben gezeigt von Hand ändern. -### How to check if your operating system is 32-bit or 64-bit? +### Wie überprüfe ich, ob mein Betriebssystem eine 32-Bit oder 64-Bit Variante ist? -Our next step depends on your operating system type, so we have to check it before we download the standard installation packages. +Der nächste Schritt hängt von der Art Deines Betriebssystems ab. Deshalb müssen wir diese erst herausfinden, bevor wir mit der Installation beginnen. -If you are using Windows, press `Win+R` and then run the command tool. Type the `systeminfo` command and it will show you some useful system information. Find the line that says "system type" -if you see "x64-based PC" that means your operating system is 64-bit, 32-bit otherwise. +Unter Windows, drücke `Win+R` und öffne die Kommandozeile, indem du `cmd` eingibst und `Enter` drückst. Tippe nun `systeminfo` ein und Du wirst ein paar nützliche Informationen vorfinden. Suche nach der Zeile "Systemtyp", welche die benötigten Informationen beinhaltet. Wenn Du "x64-based PC" liest, besitzt Du ein 64-Bit System, andernfalls ist es eine 32-Bit Version. -I strongly recommend downloading the 64-bit package if you are a Mac user, as Go no longer supports pure 32-bit processors on Mac OSX. +Ich empfehle Dir dringlichst die 64-Bit Version von Go herunterzuladen, solltest Du ein Mac-Benutzer sein, da Go keine reinen 32-Bit-Prozessoren mehr unter Mac OSX unterstützt. -Linux users can type `uname -a` in the terminal to see system information. -A 64-bit operating system will show the following: +Linux-Benutzer können `uname -a` im Terminal eintippen, um die Systeminformationen einzusehen. Ein 64-Bit Betriebssystem wird folgendes anzeigen: - x86_64 x86_64 x86_64 GNU/Linux - // some machines such as Ubuntu 10.04 will show as following + x86_64 x86_64 x86_64 GNU/Linux + // Einige Computer mit Ubuntu 10.04 werden folgendes ausgeben x86_64 GNU/Linux -32-bit operating systems instead show: +Ein 32-Bit System sieht dagegen folgendermaßen aus: - i686 i686 i386 GNU/Linux + i686 i686 i386 GNU/Linux ### Mac -Go to the [download page](https://golang.org/dl/), choose `go1.4.2.darwin-386.pkg` for 32-bit systems and `go1.4.2.darwin-amd64.pkg` for 64-bit systems. Going all the way to the end by clicking "next", `~/go/bin` will be added to your system's $PATH after you finish the installation. Now open the terminal and type `go`. You should see the same output shown in igure 1.1. +Rufe die Seite zum [Herunterladen](https://golang.org/dl/) auf und wähle `go1.4.2.darwin-386.pkg` für 32-Bit Systeme und `go1.4.2.darwin-amd64.pkg` für 64-Bit Systeme. Installiere Go, indem Du immer auf "weiter" klickst. `~/go/bin` wird automatisch zur Umgebungsvariable $PATH Deines Systems am Ende der Installation hinzugefügt. Öffne nun ein Terminal und tippe `go` ein. Du solltest die selben Ausgaben wie in Abbildung 1.1 sehen. ### Linux -Go to the [download page](https://golang.org/dl/), choose `go1.4.2.linux-386.tar.gz` for 32-bit systems and `go1.4.2.linux-amd64.tar.gz` for 64-bit systems. Suppose you want to install Go in the `$GO_INSTALL_DIR` path. Uncompress the `tar.gz` to your chosen path using the command `tar zxvf go1.4.2.linux-amd64.tar.gz -C $GO_INSTALL_DIR`. Then set your $PATH with the following: `export PATH=$PATH:$GO_INSTALL_DIR/go/bin`. Now just open the terminal and type `go`. You should now see the same output displayed in figure 1.1. + +Rufe die Seite zum [Herunterladen](https://golang.org/dl/) auf und wähle `go1.4.2.linux-386.tar.gz` für 32-Bit Systeme und `go1.4.2.linux-amd64.tar.gz` für 64-Bit Systeme. Angenommen, Du willst Go im `$GO_INSTALL_DIR` Pfad installieren: entpacke das `tar.gz` Archiv und wähle Deinen Pfad mit dem Befehl `tar zxvf go1.4.2.linux-amd64.tar.gz -C $GO_INSTALL_DIR`. Dann setze die Umgebungsvariable $PATH mit `export PATH=$PATH:$GO_INSTALL_DIR/go/bin`. Öffne nun ein Terminal und gib `go` ein. Du solltest die selben Ausgaben wie in Abbildung 1.1 sehen. ### Windows -Go to the [download page](https://golang.org/dl/), choose `go1.4.2.windows-386.msi` for 32-bit systems and `go1.4.2.windows-amd64.msi` for 64-bit systems. Going all the way to the end by clicking "next", `c:/go/bin` will be added to `path`. Now just open a command line window and type `go`. You should now see the same output displayed in figure 1.1. +Rufe die Seite zum [Herunterladen](https://golang.org/dl/) auf und wähle `go1.4.2.windows-386.msi` für 32-Bit Systeme und `go1.4.2.windows-amd64.msi` für 64-Bit Systeme. Installiere Go, indem Du immer auf "weiter" klickst. `c:/go/bin` wird zu `path` hinzugefügt. Öffne nun ein Terminal und tippe `go` ein. Du solltest die selben Ausgaben wie in Abbildung 1.1 sehen. -## Use third-party tools +## Nutze Programme von Dritten ### GVM -GVM is a Go multi-version control tool developed by a third-party, like rvm for ruby. It's quite easy to use. Install gvm by typing the following commands in your terminal: +GVM ist ein Multi-Versions-Kontroll-Werkzeug'für Go und wurde von einem unabhängigen Programmier entwickelt, wie rvm für Ruby. Es ist ziemlich einfach zu nutzen. Installiere gvm indem Du folgendes in ein Terminal eingibst: bash < <(curl -s -S -L https://raw.github.com/moovweb/gvm/master/binscripts/gvm-installer) -Then we install Go using the following commands: +Dann installieren wir Go wie folgt: gvm install go1.4.2 gvm use go1.4.2 -After the process has finished, you're all set. +Ist die Installation abgeschlossen, sind wir auch schon fertig. ### apt-get -Ubuntu is the most popular desktop release version of Linux. It uses `apt-get` to manage packages. We can install Go using the following commands. +Ubuntu ist die beliebteste Desktopvariante für Linux. Es nutzt `apt-get`, um Pakete zu verwalten. Wir können Go mit den unten stehenden Befehlen installieren: sudo add-apt-repository ppa:gophers/go sudo apt-get update @@ -110,12 +114,12 @@ Ubuntu is the most popular desktop release version of Linux. It uses `apt-get` t ### Homebrew -Homebrew is a software management tool commonly used in Mac to manage packages. Just type the following commands to install Go. +Homebrew ist ein oftmals auf dem Mac genutztes Programm, um Pakete zu verwalten. Gib einfach folgendes ein, um Go zu installieren: brew install go ## Links -- [Directory](preface.md) -- Previous section: [Go environment configuration](01.0.md) -- Next section: [$GOPATH and workspace](01.2.md) +- [Inhaltsverzeichnis](preface.md) +- Vorheriger Abschnitt: [Einrichtung der Go Entwicklungsumgebung](01.0.md) +- Nächster Abschnitt: [$GOPATH und Workspaces](01.2.md) diff --git a/de/01.2.md b/de/01.2.md index b12a9029..41238470 100644 --- a/de/01.2.md +++ b/de/01.2.md @@ -1,39 +1,40 @@ -#1.2 $GOPATH and workspace +#1.2 $GOPATH und Workspaces ## $GOPATH -Go commands all rely on one important environment variable called $GOPATH. Notice that this is not the $GOROOT variable where Go is installed. This variable points to the workspace of Go on your computer (I use this path on my computer; if you don't have the same directory structure, please replace by yourself). +Alle Go-Befehle bauen auf einer wichtigen Umgebungsvariable mit dem Namen $GOPATH. Bedenke, dass es sich nicht um $GOROOT, also den Installationspfad von Go, handelt. Diese Variable verweist vielmehr auf den Go Workspace auf Deinem Computer (Ich benutze den unten stehenden Pfad auf meinem Computer; solltest Du eine andere Ordnerstruktur haben, musst Du den Pfad anpassen). + +In UNIX-ähnlichen System sollte die Variable dieser ähnlich sein: -In Unix-like systems, the variable should be used like this: - export GOPATH=/home/apple/mygo - -In Windows, you need to create a new environment variable called GOPATH, then set its value to `c:\mygo`( ***This value depends on where your workspace is located*** ) -It's OK to have more than one path (workspace) in $GOPATH, but remember that you have to use `:`(`;` in Windows) to break them up. At this point, `go get` will save the content to your first path in $GOPATH. +In Windows musst Du eine neue Umgebungsvariable mit dem Namen $GOPATH erstellen und ihren Wert auf `C:\mygo`( ***Dieser Wert ist abhängig von dem Pfad Deines Workspaces*** ) setzen. -In $GOPATH, you must have three folders as follows. +Es ist in Ordnung, mehr als einen Pfad (bzw. Workspace) im $GOPATH zu speichern, aber bedenke, dass Du die Pfade mit `:` (oder `;` unter Windows) von einander trennen musst. `go get` wird Pakete stets unter dem ersten, angegebenen Workspace speichern. -- `src` for source files whose suffix is .go, .c, .g, .s. -- `pkg` for compiled files whose suffix is .a. -- `bin` for executable files +IM $GOPATH müssen die drei bestimmte Verzeichnisse vorhanden sein: -In this book, I use `mygo` as my only path in $GOPATH. +- `src` für Quellcode mit der Dateiendung .go, .c, .g, .s. +- `pkg` für kompilierte Dateien mit der Dateiendung .a. +- `bin` für ausführbare Dateien -## Package directory -Create package source files and folders like `$GOPATH/src/mymath/sqrt.go` (`mymath` is the package name) ( ***Author uses `mymath` as his package name, and same name for the folder where contains package source files***) +In diesem Buch ist `mygo` mein einziger Pfad in $GOPATH. -Every time you create a package, you should create a new folder in the `src` directory. Folder names are usually the same as the package that you are going to use. You can have multi-level directories if you want to. For example, if you create the directory `$GOPATH/src/github.com/astaxie/beedb`, then the package path would be `github.com/astaxie/beedb`. The package name will be the last directory in your path, which is `beedb` in this case. +## Paketverzeichnis -Execute following commands. ( ***Now author goes back to talk examples*** ) +Erstelle Quellcodedateien und Ordner wie `$GOPATH/src/mymath/sqrt.go` (`mymath` ist der Paketname) ( ***Der Autor nutzt `mymath` als Paketnamen und gibt den Verzeichnissen, welche die Quellcodedateien beinhalten, den selben Namen***). + +Jedes Mal, wenn Du ein neues Paket erstellt, solltest Du einen neuen Ordner im `src` Verzeichnis erstellen. Diese Ordner haben überlicherweise den selben Namen, wie das Paket, welches Du nutzen möchtest. Die Verzeichnisse können zudem beliebig verschachtelt werden. Erstellst Du beispielsweise das Verzeichnis `$GOPATH/src/github.com/astaxie/beedb`, dann wäre das entsprechende Paket `github.com/astaxie/beedb`. Das Paket ist immer das letzte Verzeichnis im Pfad, in diesem Fall `beedb`. + +Führe die Folgenden Befehle aus. ( ***Nun widmet sich der Autor wieder den praktischen Dingen.*** ) cd $GOPATH/src mkdir mymath -Create a new file called `sqrt.go`, type following content to your file. +Erstelle eine neue Datei mit dem Namen `sqrt.go`, die folgendes beinhalten soll. - // Source code of $GOPATH/src/mymath/sqrt.go + // Quellcode von $GOPATH/src/mymath/sqrt.go package mymath func Sqrt(x float64) float64 { @@ -44,35 +45,36 @@ Create a new file called `sqrt.go`, type following content to your file. return z } -Now my package directory has been created and its code has been written. I recommend that you use the same name for your packages as their corresponding directories, and that the directories contain all of the package source files. +Nun haben wir das Paketverzeichnis und den dazugehörigen Quellcode. Ich empfehle Dir, alle Paketverzeichnisse nach dem Paket selbst zu benennen und den gesamten, dazugehörigen Quellcode dort zu speichern. -## Compile packages +## Pakete kompilieren -We've already created our package above, but how do we compile it for practical purposes? There are two ways to do this. +Oben haben wir bereits unser Paket erstellt, aber wie kompilieren wir es, um es nutzen zu können? Dafür gibt es zwei Wege. -1. Switch your work path to the directory of your package, then execute the `go install` command. -2. Execute the above command except with a file name, like `go install mymath`. +1. Navigiere im Terminal zum Paketverzeichnis und führe den `go install` Befehl aus. +2. Führe den oberen Befehl aus, diesmal jedoch mit einem Dateinamen wie `go install mymath`. -After compiling, we can open the following folder. + +Nach der Kompilierung können wir den folgenden Ordner öffnen. cd $GOPATH/pkg/${GOOS}_${GOARCH} - // you can see the file was generated + // Wie Du siehst, wurde eine neue Datei erstellt mymath.a -The file whose suffix is `.a` is the binary file of our package. How do we use it? +Die Datei mit der Endung `.a` ist die Binärdatei unseres Pakets. Aber wie nutzen wie diese nun? -Obviously, we need to create a new application to use it. +Logischerweise müssen wir dafür eine neue Anwendung schreiben, um das Paket zu nutzen. -Create a new application package called `mathapp`. +Erstelle ein neues Paket für die Anwendung mit dem Namen `mathapp`. cd $GOPATH/src mkdir mathapp cd mathapp vim main.go -code +Und der Code: - //$GOPATH/src/mathapp/main.go source code. + // Quellcode von $GOPATH/src/mathapp/main.go package main import ( @@ -81,24 +83,24 @@ code ) func main() { - fmt.Printf("Hello, world. Sqrt(2) = %v\n", mymath.Sqrt(2)) + fmt.Printf("Hallo, Welt. Sqrt(2) = %v\n", mymath.Sqrt(2)) } -To compile this application, you need to switch to the application directory, which in this case is `$GOPATH/src/mathapp`, then execute the `go install` command. Now you should see an executable file called `mathapp` was generated in the directory `$GOPATH/bin/`. To run this program, use the `./mathapp` command. You should see the following content in your terminal. +Um die Anwendung zu kompilieren, müssen wir zurück in das Verzeichnis, in welchem die Anwendung liegt; in diesem diesem Falle unter `$GOPATH/src/mathapp`. Führe nun den Befehl `go install` aus. Nun solltest Du eine neue ausführbare Datei mit dem Namen `mathapp` im Verzeichnis `$GOPATH/bin/` vorfinden. Um das Programm auszuführen, tippe den Befehl `./mathapp` ein. Im Terminal solltest Du nun den unteren Text lesen können. - Hello world. Sqrt(2) = 1.414213562373095 + Hallo, Welt. Sqrt(2) = 1.414213562373095 -## Install remote packages +## Installation von Paketen Dritter (Remote Packages) -Go has a tool for installing remote packages, which is a command called `go get`. It supports most open source communities, including Github, Google Code, BitBucket, and Launchpad. +Go umfasst ein Werkzeug zum Installieren von Remote Packages, also Paketen die von anderen Programmierern erstellt wurden. Mit dem Befehl `go get` kannst Du diese für die eigene Nutzung installieren. Es unterstützt die meisten Open Source Communities wie Github, Google Code, Bitbucket und Launchpad. go get github.com/astaxie/beedb -You can use `go get -u …` to update your remote packages and it will automatically install all the dependent packages as well. +Du kannst `go get -u …` nutzen, um ein Remote Package zu aktualisieren. Zugleich werden auch alle benötigten Abhängigkeiten mit installiert. -This tool will use different version control tools for different open source platforms. For example, `git` for Github and `hg` for Google Code. Therefore, you have to install these version control tools before you use `go get`. +Dieser Befehl nutzt verschiedene Versionskontrollsysteme für die verschiedenen Open Source Plattformen. So wird beispielsweise `git` für Github und `hg` für Google Code verwendet. Daher musst Du zuerst die entsprechenden Versionskontrollsysteme installieren, ehe Du `go get` nutzen kannst. -After executing the above commands, the directory structure should look like following. +Nach dem Ausführen der oben gezeigten Befehle, sollte die Orderstruktur etwa so aussehen. $GOPATH src @@ -111,15 +113,15 @@ After executing the above commands, the directory structure should look like fol |-astaxie |-beedb.a -Actually, `go get` clones source code to the $GOPATH/src of the local file system, then executes `go install`. +Im Hintergrund "klont" `go get` den Quellcode nach $GOPATH/src auf deinem Computer und nutzt dann `go install` zur Installation der Remote Packages. -You can use remote packages in the same way that we use local packages. +Du kannst Remote Packages wie lokale Pakete nutzen. import "github.com/astaxie/beedb" -## Directory complete structure +## Die komplette Verzeichnisstruktur -If you've followed all of the above steps, your directory structure should now look like the following. +Wenn Du alle Schritte befolgt hast, sollte Deine Verzeichnisstruktur wie folgt aussehen. bin/ mathapp @@ -140,12 +142,12 @@ If you've followed all of the above steps, your directory structure should now l beedb.go util.go -Now you are able to see the directory structure clearly; `bin` contains executable files, `pkg` contains compiled files and `src` contains package source files. +Nun kannst Du die Ordnerstruktur klar erkennen. `bin` beinhaltet alle ausführbaren Dateien, `pkg` alle compilierten Dateien und `src` den Quellcode der Pakete. -(The format of environment variables in Windows is `%GOPATH%`, however this book mainly follows the Unix-style, so Windows users need to replace these yourself.) +(Das Format von Umgebungsvariable unter Windows ist `%GOPATH%`. Da dieses Buch sich jedoch am UNIX-Stil orientiert, müssen Windowsnutzer das Format von Hand ändern.) ## Links -- [Directory](preface.md) -- Previous section: [Installation](01.1.md) -- Next section: [Go commands](01.3.md) +- [Inhaltsverzeichnis](preface.md) +- Vorheriger Abschnitt: [Installation](01.1.md) +- Nächster Abschnitt: [Go Befehle](01.3.md) diff --git a/de/01.3.md b/de/01.3.md index c544f065..54367e6c 100644 --- a/de/01.3.md +++ b/de/01.3.md @@ -1,106 +1,109 @@ -#1.3 Go commands +#1.3 Go Befehle -## Go commands +## Go Befehle -The Go language comes with a complete set of command operation tools. You can execute the command line `go` to see them: +Die Programmiersprache Go bringt viele nützliche Befehle für diverse Anwendungszwecke mit sich. Du erhälst eine Übersicht, indem Du `go` im Terminal ausführst. ![](images/1.3.go.png?raw=true) -Figure 1.3 Go command displays detailed information +Figure 1.3 Eine detaillierte Übersicht aller Go Befehle -These are all useful for us. Let's see how to use some of them. +Jeder Befehl kann nützlich für uns sein. Betrachten wir den Anwendungszweck von ein paar Befehlen. ## go build -This command is for compiling tests. It will compile dependence packages if it's necessary. +Dieser Befehl ist für die Kompilierung und das Testen des Quellcodes verantwortlich. Abhängige Pakete werden ebenfalls mit kompiliert, sofern dies nötig ist. -- If the package is not the `main` package such as `mymath` in section 1.2, nothing will be generated after you execute `go build`. If you need package file `.a` in `$GOPATH/pkg`, use `go install` instead. -- If the package is the `main` package, it will generate an executable file in the same folder. If you want the file to be generated in `$GOPATH/bin`, use `go install` or `go build -o ${PATH_HERE}/a.exe.` -- If there are many files in the folder, but you just want to compile one of them, you should append the file name after `go build`. For example, `go build a.go`. `go build` will compile all the files in the folder. -- You can also assign the name of the file that will be generated. For instance, in the `mathapp` project (in section 1.2), using `go build -o astaxie.exe` will generate `astaxie.exe` instead of `mathapp.exe`. The default name is your folder name (non-main package) or the first source file name (main package). +- Wenn das Paket nicht `main` entspricht, wie unser `mymath` Paket aus Abschnitt 1.2 nicht ausgeführt, nachdem Du `go build` ausgeführt hast. Solltest Du Paket-Dateien mit der Endung `.a` in `$GOPATH/pkg`, nutze stattdessen `go install`. +- Sollte das Paket `main` entsprechen, dann wird eine ausführbare Binärdatei im selben Verzeichnis generiert. Möchtest Du stattdessen, dass Die Binärdatei in `$GOPATH/bin` generiert wird, nutze den Befehl `go install` oder `go build -o ${PATH_HERE}/a.exe.`. +- Befinden sich viele Dateien in einem Ordner, aber Du möchtest nur eine bestimmte Datei kompilieren, dann füge den Dateinamen am Ende von `go build` hinzu. Ein Beispiel wäre `go build a.go`. `go build` wird alle Dateien im selben Ordner kompilieren. +- Du kannst alternativ auch den Namen der ausführbaren Binärdatei ändern. So erhält das `mathapp` Projekt (aus Abschnitt 1.2) mit dem Befehl `go build -o astaxie.exe` den Namen `astaxie.exe`, statt `mathapp.exe`. Der Standardname ist immer der Verzeichnisname (sofern es kein `main` Paket ist) oder der Name der ersten, ausführbaren Datei (`main` Paket). -(According to [The Go Programming Language Specification](https://golang.org/ref/spec), package names should be the name after the word `package` in the first line of your source files. It doesn't have to be the same as the folder name, and the executable file name will be your folder name by default.]) +Laut den [Spezifikationen der Go Programmiersprache](https://golang.org/ref/spec) sollten Pakete den Namen tragen, der nach dem Schlüsselwort `package` in der ersten Zeile einer Quellcodedatei steht. Dieser muss nicht gleich dem Verzeichnisnamen sein und die ausführbare Binärdatei wird standardmäßig den Verzeichnisnamen annehmen. -- `go build` ignores files whose names start with `_` or `.`. -- If you want to have different source files for every operating system, you can name files with the system name as a suffix. Suppose there are some source files for loading arrays. They could be named as follows: +- `go build` ignoriert Dateien, die mit `_` oder `.` beginnen. +- Möchtest Du für jedes Betriebssystem andere Quellcodedateien erstellen, dann kannst Du den Systemnamen als Suffix im Dateinamen verwenden. Stell Dir vor, Du hast Quellcodedateien zum Laden von Arrays. Sie könnten nach dem folgenden Schema benannt sein: array_linux.go | array_darwin.go | array_windows.go | array_freebsd.go -`go build` chooses the one that's associated with your operating system. For example, it only compiles array_linux.go in Linux systems, and ignores all the others. +`go build` wählt als Suffix den Namen, der mit Deinem Betriebssystem assoziiert ist. So wird einzig `array_linux.go` auf Linux-Systemen kompiliert. Alle anderen Dateien werden ignoriert. ## go clean -This command is for cleaning files that are generated by compilers, including the following files: +Dieser Befehl löscht alle Dateien, die vom Kompiler generiert wurden, einschließlich der unten gelisteten Dateien und Verzeichnisse. - _obj/ // old directory of object, left by Makefiles - _test/ // old directory of test, left by Makefiles - _testmain.go // old directory of gotest, left by Makefiles - test.out // old directory of test, left by Makefiles - build.out // old directory of test, left by Makefiles - *.[568ao] // object files, left by Makefiles + _obj/ // Altes Verzeichnis von object, als Überreste von Makefiles + _test/ // Altes Verzeichnis von test, als Überreste von Makefiles + _testmain.go // Altes Verzeichnis von gotest, als Überreste von Makefiles + test.out // Altes Verzeichnis von test, als Überreste von Makefiles + build.out // Altes Verzeichnis von test, als Überreste von Makefiles + *.[568ao] // object Dateien, als Überreste von Makefiles - DIR(.exe) // generated by go build - DIR.test(.exe) // generated by go test -c - MAINFILE(.exe) // generated by go build MAINFILE.go - -I usually use this command to clean up my files before I upload my project to Github. These are useful for local tests, but useless for version control. + DIR(.exe) // Generiert von go build + DIR.test(.exe) // Generiert von go test -c + MAINFILE(.exe) // Generiert von go build MAINFILE.go -## go fmt and gofmt +Überlicherweise nutze ich diese Befehle zum Säubern von Projekten, bevor ich diese auf Github hochlade. Sie sind nützlich für lokale Tests, aber nutzlos zur Versionskontrolle. -The people who are working with C/C++ should know that people are always arguing about which code style is better: K&R-style or ANSI-style. However in Go, there is only one code style which is enforced. For example, left braces must only be inserted at the end of lines, and they cannot be on their own lines, otherwise you will get compile errors! Fortunately, you don't have to remember these rules. `go fmt` does this job for you. Just execute the command `go fmt .go` in terminal. I don't use this command very much because IDEs usually execute this command automatically when you save source files. I will talk about IDEs more in the next section. +## go fmt und gofmt -`go fmt` is just an alias, which runs the command 'gofmt -l -w' on the packages named by the import paths. +Programmierer, die mit C/C++ arbeiten, sollten wissen, das Personen immer darüber debattieren, welcher Code-Stil besser sei: K&R-Stil oder ANSI-Stil. In Go gibt nur einen einzigen, welcher vorrausgesetzt wird. So müssen zum Beispiel offene, geschwungene Schleifen nur am Ende von Zeilen eingefügt werden und können nicht in einer eigenen stehen, da dies einen Kompilierungsfehler zur Folge hat! Jedoch musst Du Dir diese Regeln nicht merken. `go fmt` übernimmt diese Aufgabe für Dich. Führe einfach den Befehl `go fmt .go` im Terminal aus. Persönlich nutze ich diesen Befehl selten, da die meisten IDEs diesen Befehl meist automatisch ausführen, sobald ich eine Datei speichere. Im nächsten Abschnitt werde ich näher auf IDEs eingehen. -We usually use `gofmt -w` instead of `go fmt`. The latter will not rewrite your source files after formatting code. `gofmt -w src` formats the whole project. + +`go fmt` ist nur ein Alias, welcher den Befehl `gofmt -l -w` bei Paketen anwendet, die in den Importpfaden genannt werden. + +Wir nutzen üblicherweise `gofmt -w` statt `go fmt`. Somit wird Deine Quellcodedatei nicht umgeschrieben, nachdem sie formatiert wurde. `gofmt -w src` formatiert dagegen ein gesamtes Projekt. ## go get -This command is for getting remote packages. So far, it supports BitBucket, Github, Google Code and Launchpad. There are actually two things that happen after we execute this command. The first thing is that Go downloads the source code, then executes `go install`. Before you use this command, make sure you have installed all of the related tools. +Dieser Befehl ermöglicht es, Remote Packages herunterzuladen. Bisher untersützt es Bitbucket, Github, Google Code und Launchpad. Es geschehen zwei Dinge, nachdem wir den Befehl ausgeführt haben. Als erstes lädt Go den Quellcode herunter und führt danach `go install` aus. Bevor Du `go get` nutzt, solltest Du vorher die benötigten Versionskontrollsysteme herunterladen. - BitBucket (Mercurial Git) - Github (git) + BitBucket (Mercurial und Git) + Github (Git) Google Code (Git, Mercurial, Subversion) Launchpad (Bazaar) -In order to use this command, you have to install these tools correctly. Don't forget to set `$PATH`. By the way, it also supports customized domain names. Use `go help remote` for more details about this. + +Um den Befehl auch nutzen zu können, musst Du diese Programme korrekt installieren. Vergiss nicht, `$PATH` zu setzen. Angemerkt sei, dass auch angepasste Domainnamen unterstützt werden. Nutze `go help remote`, um weitere Informationen zu erhalten. ## go install -This command compiles all packages and generates files, then moves them to `$GOPATH/pkg` or `$GOPATH/bin`. +Dieser Befehl kompiliert alle Pakete und generiert Dateien, die entweder nach `$GOPATH/pkg` oder `$GOPATH/bin` verschoben werden. ## go test -This command loads all files whose name include `*_test.go` and generates test files, then prints information that looks like the following. +Dieser Befehl läd alle Dateinen, dessen Name `*_test.go` beinhaltet, generiert Dateien für Tests und gibt anschließend dessen Ergebnisse aus, die wie folgt aussehen können: ok archive/tar 0.011s FAIL archive/zip 0.022s ok compress/gzip 0.033s ... -It tests all your test files by default. Use command `go help testflag` for more details. +Es nutzt standardmäßig alle vorhanden Test-Dateien. Schaue unter `go help testflag` für Details. ## godoc -Many people say that we don't need any third-party documentation for programming in Go (actually I've made a [CHM](https://github.com/astaxie/godoc) already). Go has a powerful tool to manage documentation natively. +Viele Personen sagen, man brauche kein Dokumentationswerkzeug von Dritten, wenn man Go nutzt (obwohl ich mit [CHM](https://github.com/astaxie/godoc) selbst eins schrieb). Go besitzt ein mächtiges Wergzeug, um Dokumentationen nativ zu verwalten. -So how do we look up package information in documentation? For instance, if you want to get more details about the `builtin` package, use the `godoc builtin` command. Similarly, use the `godoc net/http` command to look up the `http` package documentation. If you want to see more details about specific functions, use the `godoc fmt Printf` and `godoc -src fmt Printf` commands to view the source code. +Aber wie können wir bestimmte Informationen über ein Paket einsehen? So möchtest Du zum Beispiel mehr über das `builtin` Paket wissen. Nutze hierfür `godoc builtin`. Mach es mit `godoc net/http` genauso, wenn Du mehr über das `http` Paket in Erfahrung bringen möchtest. Ist jedoch eine spezifische Funktion gefragt, benutze die `godoc fmt Printf` und `godoc -src fmt Printf` Befehle, um den Quellcode zu betrachten. -Execute the `godoc -http=:8080` command, then open `127.0.0.1:8080` in your browser. You should see a localized golang.org. It can not only show the standard packages' information, but also packages in your `$GOPATH/pkg`. It's great for people who are suffering from the Great Firewall of China. +Führe den Befehl `godoc -http=:8080` aus und öffne dann `127.0.0.1:8080` in Deinem Browser. Nun solltest Du eine Deiner Sprache angepassten (lokalisierten) Version von golang.org sehen. So kannst Du nicht nur die Dokumentationen zu Paketen der Standardbibliothek ansehen, sondern auch aller Pakete, die unter `$GOPATH/pkg` gepspeichert sind. Dies ist großartig für Menschen, die von der Great Firewall of China im Internet eingeschränkt werden. -## Other commands +## Andere Befehle -Go provides more commands than those we've just talked about. +Go verfügt über noch mehr Befehle, die wir nicht behandelt haben. - go fix // upgrade code from an old version before go1 to a new version after go1 - go version // get information about your version of Go - go env // view environment variables about Go - go list // list all installed packages - go run // compile temporary files and run the application + + go fix // Überführt alten Go Code von Go1 oder niedriger in eine neuere Version + go version // Erhalte nähere Informationen über Deine Go Version + go env // Zeigt die alle Umgebungsvariablen von Go + go list // Listed alle installierten Pakete + go run // Kompiliert temporäre Dateien und führt diese aus -There are also more details about the commands that I've talked about. You can use `go help ` to look them up. +Es gibt noch weitere Aspekte zu den Befehlen, über die ich nicht gesprochen habe. Du kannst `go help ` nutzen, um diese nachzulesen. ## Links -- [Directory](preface.md) -- Previous section: [$GOPATH and workspace](01.2.md) -- Next section: [Go development tools](01.4.md) +- [Inhaltsverzeichnis](preface.md) +- Vorheriger Abschnitt: [$GOPATH und Workspaces](01.2.md) +- Nächster Abschnitt: [Go Entwicklungswerkzeuge](01.4.md) diff --git a/de/01.4.md b/de/01.4.md index 8126d76e..ad65518b 100644 --- a/de/01.4.md +++ b/de/01.4.md @@ -1,66 +1,65 @@ -# Go development tools +# Go Entwicklungswerkzeuge -In this section, I'm going to show you a few IDEs that can help you become a more efficient programmer, with capabilities such as intelligent code completion and auto-formatting. They are all cross-platform, so the steps I will be showing you should not be very different, even if you are not using the same operating system. +In diesem Abschnitt werde ich Dir ein paar IDEs (***Integrated Developement Environments***) vorstellen, die Dir mit Funktionen wie intelligenter Codevervollständigung und automatischer Formatierung dabei helfen, effizienter zu programmieren. Alle Entwicklungsumgebungen sind plattformunabhängig, sodass die hier gezeigten Schritte nicht sehr verschieden seien sollten, auch wenn Du ein anderes Betriebssystem nutzt. ## LiteIDE -LiteIDE is an open source, lightweight IDE for developing Go projects only, developed by visualfc. +LiteIDE ist eine leichtgewichtige IDE, die open source ist und einzig für die Go Programmierung gedacht ist. Entwickelt wurde sie von visualfc. ![](images/1.4.liteide.png?raw=true) -Figure 1.4 Main panel of LiteIDE +Abbildung 1.4 Startansicht von LiteIDE -LiteIDE features. +LiteIDEs Merkmale. -- Cross-platform +- Plattformunaghängigkeit - Windows - Linux - Mac OS -- Cross-compile - - Manage multiple compile environments - - Supports cross-compilation of Go -- Project management standard - - Documentation view based on $GOPATH - - Compilation system based on $GOPATH - - API documentation index based on $GOPATH -- Go source code editor - - Code outlining - - Full support of gocode - - Go documentation view and API index - - View code expression using `F1` - - Function declaration jump using `F2` - - Gdb support - - Auto-format with `gofmt` -- Others - - Multi-language - - Plugin system - - Text editor themes - - Syntax support based on Kate - - intelligent completion based on full-text - - Customized shortcuts - - Markdown support - - Real-time preview - - Customized CSS - - Export HTML and PDF - - Convert and merge to HTML and PDF +- Plattformübergreifende Kompilierung + - Verwalte mehrere Kompilierungsumgebungen + - Unterstützt die plattformübergreifende Kompilierung von Go-Code +- Standardisiertes Projektmanagement + - Dokumentationsansicht basiert auf $GOPATH + - Kompilierungsystem basiert auf $GOPATH + - Index der API-Dokumentation basiert auf $GOPATH +- Go Quellcode Editor + - Umschreibung von Code + - Vollständige Unterstützung von gocode + - Anzeige der Go Dokumentation und ein API Index + - Hilfe zu Codefragmenten durch `F1` + - Aufrufen von Funktionsdeklerationen durch `F2` + - Gdb Unterstützung + - Automatische Formatierung durch `gofmt` +- Anderes + - Mehrsprachig + - Plugin System + - Texteditor Themes + - Farbliche Syntaxhervorhebung basierend auf Kate + - Intelligente Autovervollständigung basierend auf einer Volltext-Suche + - Personalisierbare Tastenkürzel + - Markdown Unterstützung + - Echtzeit Vorschau + - Personalisierbares CSS + - Exportoptioen zu HTML und PDF + - Konvertierung and Zusammenführung zu HTML und PDF -### LiteIDE installation +### LiteIDE Instalation -- Install LiteIDE - - [Download page](http://code.google.com/p/golangide) - - [Source code](https://github.com/visualfc/liteide) +- Installiere LiteIDE + - [Lade LiteIDE herunter](http://code.google.com/p/golangide) + - [Quellcode](https://github.com/visualfc/liteide) - You need to install Go first, then download the version appropriate for your operating system. Decompress the package to directly use it. -- Install gocode + Du musst Go zuerst installieren. Lade dafür die entsprechende Version für Dein Betriebssystem herunter. Entpacke das Archiv um es Programm direkt auszuführen. +- Installiere gocode - You have to install gocode in order to use intelligent completion + Im nächsten Schritt muss gocode installiert werden, um die intelligente Autovervollständigung zu nutzen. go get -u github.com/nsf/gocode -- Compilation environment +- Kompilierungsumgebung - Switch configuration in LiteIDE to suit your operating system. - In Windows and using the 64-bit version of Go, you should choose win64 as the configuration environment in the tool bar. Then, choose `opinion`, find `LiteEnv` in the left list and open file `win64.env` in the right list. + Passe die Einstellungen von LiteIDE Deinen Betriebssystem entprechend an. Unter Windows mit der 64-Bit Variante von Go solltest Du win64 als Umgebung in der Symbolleiste auswählen. Dann wähle `opinion`, finde `LiteEnv` in der Liste auf der linken Seiten und öffne die Datei `win64.env` in der Liste zu Deiner Rechten. GOROOT=c:\go GOBIN= @@ -71,9 +70,9 @@ LiteIDE features. PATH=%GOBIN%;%GOROOT%\bin;%PATH% 。。。 - Replace `GOROOT=c:\go` to your Go installation path, save it. If you have MinGW64, add `c:\MinGW64\bin` to your path environment variable for `cgo` support. - - In Linux and using the 64-bit version of Go, you should choose linux64 as the configuration environment in the tool bar. Then, choose `opinion`, find `LiteEnv` in the left list and open the `linux64.env` file in the right list. + Ersetze `GOROOT=c:\go` mit Deinem Installationspfad von Go und speichere. Wenn Du MinGW64 nutzt, füge `C:\MinGW64\bin` der $PATH-Umgebungsvariable hinzu, um `cgo` starten zu können. + + Unter Linux mit einer 64-Bit Variante von Go, solltest Du linux64 als Umgebung in der Symbolleiste auswählen. Dann wähle `opinion`, finde `LiteEnv` in der Liste auf der linken Seiten und öffne die Datei `linux64.env` in der Liste zu Deiner Rechten. GOROOT=$HOME/go GOBIN= @@ -84,78 +83,79 @@ LiteIDE features. PATH=$GOBIN:$GOROOT/bin:$PATH 。。。 - Replace `GOROOT=$HOME/go` to your Go installation path, save it. + Ersetzte `GOROOT=$HOME/go` mit Deinem Installationspfad von Go und speichere. - $GOPATH - $GOPATH is the path that contains a list of projects. Open the command tool (or press ``Ctrl+` ``in LiteIDE), then type `go help gopath` for more details. - It's very easy to view and change $GOPATH in LiteIDE. Follow `View - Setup GOPATH` to view and change these values. + $GOPATH ist ein Pfad, der eine Liste von allen Go-Projekten umfasst. Öffne die Kommandozeile (oder drücke `Ctrl+` in LiteIDE) und gib dann `go help gopath` ein, um mehr Details einzusehen. In LiteIDE ist es sehr einfach, den $GOPATH einzusehen und ihn zu verändern. Folge `View - Setup GOPATH`, um dies zu tun. ## Sublime Text -Here I'm going to introduce you the Sublime Text 2 (Sublime for short) + GoSublime + gocode + MarGo. Let me explain why. +Nun möchte ich dir Sublime Text 2 (oder einfach Sublime) in Kombination mit den Plugins GoSublime, gocode und MarGo vorstellen. Lass mich erklären, warum. -- Intelligent completion +- Intelligente Autovervollständigung ![](images/1.4.sublime1.png?raw=true) - Figure 1.5 Sublime intelligent completion -- Auto-format source files -- Project management + Abbildung 1.5 Sublimes intelligente Autovervollständigung +- Automatische Formatierung des Quellcodes +- Unterstützung für Projektmanagement ![](images/1.4.sublime2.png?raw=true) - Figure 1.6 Sublime project management + Abbildung 1.6 Projektmanagement in Sublime -- Syntax highlight -- Free trial forever with no functional limitations. You may be prompted once in a while to remind you to purchase a license, but you can simply ignore it if you wish. Of course, if you do find that it enhances your productivity and you really enjoy using it, please purchase a copy of it and support its continued development! +- Farbliche Hervorhebung des Synax +- Es gibt eine Testversion ohne Einschränkungen der Funktionen. Es kann sein, dass Du nach einer Weile daran erinnert wirst, dass Du eine Lizenz kaufen sollest, aber Du kannst diese Meldung auch einfach ignorieren. Wenn Du aber glaubst, dass Sublime Dich produktiver macht und Du den Editor magst, solltest Du eine Lizenz kaufen, um die fortwährende Entwicklung zu unterstützen. -First, download the version of [Sublime](http://www.sublimetext.com/) suitable for your operating system. +Zu aller erst solltest Du Dir eine für Dein Betriebssystem geeignete Version von [Sublime](http://www.sublimetext.com/) herunterladen. -1. Press ``Ctrl+` ``, open the command tool and input the following commands. +1. Drücke ``Ctrl+` ``, öffne die Kommandozeile und füge folgenden Codesnippsel ein: import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation' - Restart Sublime text when the installation has finished. You should then find a `Package Control` option in the "Preferences" menu. + Starte Sublime Text nach der Installation neu. Nun solltest Du im Menü unter dem Reiter `Preferences` die Option `Package Control` vorfinden. ![](images/1.4.sublime3.png?raw=true) - Figure 1.7 Sublime Package Control -2. To install GoSublime, SidebarEnhancements and Go Build, press `Ctrl+Shift+p` to open Package Control, then type `pcip` (short for "Package Control: Install Package"). + Abbildung 1.7 Die Paketverwaltung von Sublime + +2. Zur Installation von GoSublime, SidebarEnhancements und Go Build, drücke `Ctrl+Shift+p` um die Paketverwaltung aufzurüfen und gib `pcip` (Kurzform für "Package Control: Install Package") ein. ![](images/1.4.sublime4.png?raw=true) - Figure 1.8 Sublime Install Packages + Abbildung 1.8 Installation von Paketen in Sublime - Now type in "GoSublime", press OK to install the package, and repeat the same steps for installing SidebarEnhancements and Go Build. Once again, restart the editor when it completes the installation. -3. To verify that the installation is successful, open Sublime, then open the `main.go` file to see if it has the proper syntax highlighting. Type `import` to see if code completion prompts appear. After typing `import "fmt"`, type `fmt.` anywhere after the `import` declaration to see whether or not intelligent code completion for functions was successfully enabled. + Gib nun "GoSublime" ein, drücke auf OK, um das Paket zu installieren und wiederhole diese Schritte jeweils für SidebarEnhancements und Go Build. Starte den Editor nochmals neu, sobald alle Pakete installiert wurden. - If everything is fine, you're all set. +3. Um sicher zu stellen, dass die Installation auch erfolgreich abgeschlossen wurde, starte Sublime und öffne die Datei `main.go`, um zu sehen, ob dessen Syntax farblich hervorgehoben wird. Gib `import` ein, um zu testen, ob die automatische Codevervollständigung nun funktioniert oder nicht. + + Wenn alles erfolgreich Verlaufen ist, können wir ja starten. - If not, check your $PATH again. Open terminal, type `gocode`. If it does not run, your $PATH was not configured correctly. + Sollte dies nicht der Fall sein, solltest Du nochmal einen Blick auf die $PATH-Umgebungsvariable blicken. Öffne dazu die Kommandozeile und gib `gocode` ein. Sollte nichts ausgeführt werden, so wird $PATH wahrscheinlich nicht richtig konfiguriert worden sein. ## Vim -Vim is a popular text editor for programmers, which evolved from its slimmer predecessor, Vi. It has functions for intelligent completion, compilation and jumping to errors. +Vim ist ein populärer Texteditor unter Programmierern, welcher sich aus seinem minimalistischeren Vorgänger Vi hervorging. Zu seinen Funktionen gehören u.a. die intelligente Autovervollständung von Codesegmenten, Kompilierung und das Springen zu Fehlern im Quellcode. ![](images/1.4.vim.png?raw=true) -Figure 1.8 Vim intelligent completion for Go +Abbildung 1.8 Vims intelligente Autovervollständigung für Go -1. Syntax highlighting for Go +1. Syntaxhervorhebung für Go cp -r $GOROOT/misc/vim/* ~/.vim/ -2. Enabling syntax highlighting +2. Syntaxhervorhebung aktivieren filetype plugin indent on syntax on -3. Install [gocode](https://github.com/nsf/gocode/) +3. Installiere [gocode](https://github.com/nsf/gocode/) go get -u github.com/nsf/gocode - gocode will be installed in `$GOBIN` as default + gocode wird standardmäßig unter `$GOBIN` installiert. -4. Configure [gocode](https://github.com/nsf/gocode/) +4. Konfiguriere [gocode](https://github.com/nsf/gocode/) ~ cd $GOPATH/src/github.com/nsf/gocode/vim ~ ./update.bash @@ -167,31 +167,31 @@ Figure 1.8 Vim intelligent completion for Go propose-builtins true lib-path "/home/border/gocode/pkg/linux_amd64" - Explanation of gocode configuration: + Einige Worte zur Konfiguration von gocode: - propose-builtins: specifies whether or not to open intelligent completion; false by default. - lib-path: gocode only searches for packages in `$GOPATH/pkg/$GOOS_$GOARCH` and `$GOROOT/pkg/$GOOS_$GOARCH`. This setting can be used to add additional paths. + propose-builtins: aktiviert bzw. deaktiviert die Autovervollständigung; standardmäßig auf false gesetzt. + lib-path: gocode sucht lediglich unter `$GOPATH/pkg/$GOOS_$GOARCH` und `$GOROOT/pkg/$GOOS_$GOARCH` nach Paketen. Mit dieser Einstellung können weitere Pfade hinzugefügt werden.. -5. Congratulations! Try `:e main.go` to experience the world of Go! +5. Glückwunsch! Tippe `:e main.go` ein und mache Deine ersten Schritte in Go! ## Emacs -Emacs is the so-called Weapon of God. She is not only an editor, but also a powerful IDE. +Emacs wird auch als "Weapon of God" bezeichnet. Es handelt sich nicht nur um einen Editor, sondern vielmehr um eine mächtige IDE. ![](images/1.4.emacs.png?raw=true) -Figure 1.10 Emacs main panel of Go editor +Abbildung 1.10 Emacs Hauptfenster als Go-Editor -1. Syntax highlighting +1. Syntaxhervorhebung cp $GOROOT/misc/emacs/* ~/.emacs.d/ -2. Install [gocode](https://github.com/nsf/gocode/) +2. Installiere [gocode](https://github.com/nsf/gocode/) go get -u github.com/nsf/gocode - gocode will be installed in `$GOBIN` as default -3. Configure [gocode](https://github.com/nsf/gocode/) + gocode wird standardmäßig unter `$GOBIN` installiert. +3. Konfiguriere [gocode](https://github.com/nsf/gocode/) ~ cd $GOPATH/src/github.com/nsf/gocode/vim ~ ./update.bash @@ -203,12 +203,11 @@ Figure 1.10 Emacs main panel of Go editor propose-builtins true lib-path "/home/border/gocode/pkg/linux_amd64" -4. Install [Auto Completion](http://www.emacswiki.org/emacs/AutoComplete) - Download and uncompress +4. Installiere [Auto Completion](http://www.emacswiki.org/emacs/AutoComplete) ~ make install DIR=$HOME/.emacs.d/auto-complete - Configure ~/.emacs file + Konfiguriere die ~/.emacs-Datei ;;auto-complete (require 'auto-complete-config) @@ -218,8 +217,9 @@ Figure 1.10 Emacs main panel of Go editor (local-set-key "." 'semantic-complete-self-insert) (local-set-key ">" 'semantic-complete-self-insert) - Follow this [link](http://www.emacswiki.org/emacs/AutoComplete) for more details. -5. Configure .emacs + Folge diesem [Link](http://www.emacswiki.org/emacs/AutoComplete) für weitere Informationen. + +5. Konfiguriere .emacs ;; golang mode (require 'go-mode-load) @@ -305,95 +305,97 @@ Figure 1.10 Emacs main panel of Go editor (interactive) (show-all) (shell-command-on-region (point-min) (point-max) "go tool fix -diff")) -6. Congratulations, you're done! Speedbar is closed by default -remove the comment symbols in the line `;;(speedbar 1)` to enable this feature, or you can use it through `M-x speedbar`. + +6. Glückwunsch, Du hast es geschafft! Die Schnellzugriffsleiste (Speedbar) ist standardmäßig geschlossen - Entferne die Kommentarzeichen in der Zeile `;;(speedbar 1)`, um diese Funktion zu aktivieren, oder Du benutzt die Speedbar via `M-x speedbar`. ## Eclipse -Eclipse is also a great development tool. I'll show you how to use it to write Go programs. +Eclipse ist ebenfalls ein großartiges Entwicklungswerkzeug. Ich werde Dir zeigen, wie Du mit ihm Programme in Go schreiben kannst. ![](images/1.4.eclipse1.png?raw=true) -Figure 1.1 Eclipse main panel for editing Go +Abbildung 1.1 Eclipses Hauptfenster zum Programmieren Go -1. Download and install [Eclipse](http://www.eclipse.org/) -2. Download [goclipse](https://code.google.com/p/goclipse/) +1. Herunterladen und Installation von [Eclipse](http://www.eclipse.org/) +2. Lade [goclipse](https://code.google.com/p/goclipse/) herunter [http://code.google.com/p/goclipse/wiki/InstallationInstructions](http://code.google.com/p/goclipse/wiki/InstallationInstructions) -3. Download gocode +3. Lade gocode - gocode in Github. + gocode auf Github. https://github.com/nsf/gocode - You need to install git in Windows, usually we use [msysgit](https://code.google.com/p/msysgit/) + Unter Windows musst Du git installiert haben. Wir nutzen überlicherweise [msysgit](https://code.google.com/p/msysgit/). - Install gocode in the command tool + Installiere gocode in der Kommandozeile go get -u github.com/nsf/gocode - You can install from source code if you like. -4. Download and install [MinGW](http://sourceforge.net/projects/mingw/files/MinGW/) -5. Configure plugins. + Du kannst die Installation mithilfe des Quellcodes selbst durchführen, wenn Du magst. +4. Installation von [MinGW](http://sourceforge.net/projects/mingw/files/MinGW/) +5. Konfiguration der Plugins. Windows->Preferences->Go - (1).Configure Go compiler + (1).Einrichtung des Go-Compiler ![](images/1.4.eclipse2.png?raw=true) - Figure 1.12 Go Setting in Eclipse + Abbildung 1.12 Go-Einstellungen in Eclipse - (2).Configure gocode(optional), set gocode path to where the gocode.exe is. + (2).Konfiguriere gocode(optional). Setze den Pfad zu gocode auf den Speicherort von gocode.exe. ![](images/1.4.eclipse3.png?raw=true) - Figure 1.13 gocode Setting + Abbildung 1.13 gocode-Einstellungen - (3).Configure gdb(optional), set gdb path to where the gdb.exe is. + (3).Konfiguriere gdb(optional). Setze den Pfad zu gdb auf den Speicherort von gdb.exe. ![](images/1.4.eclipse4.png?raw=true) - Figure 1.14 gdb Setting -6. Check the installation + Abbildung 1.14 gdb-Einstellungen +6. Überprüfe, ob die Installation erfolgreich verlief - Create a new Go project and hello.go file as following. + Erstelle ein neues Go-Project und eine Datei hello.go wie folgt. ![](images/1.4.eclipse5.png?raw=true) - Figure 1.15 Create new project and file + Abbildung 1.15 Erstelle ein neues Projekt und eine Datei - Test installation as follows.(you need to type command in console in Eclipse) + Überprüfe die Installation wie folgt. (Die Befehle müssen in die Konsole von Eclipse eingegeben werden). ![](images/1.4.eclipse6.png?raw=true) - Figure 1.16 Test Go program in Eclipse + Abbildung 1.16 Teste ein Go-Programm in Eclipse ## IntelliJ IDEA -People who have worked with Java should be familiar with this IDE. It supports Go syntax highlighting and intelligent code completion, implemented by a plugin. +Programmierer, die bereits mit Java gearbeitet haben, sollte diese IDE bekannt sein. Es unterstützt die farbliche Hervorhebung von Go-Code und intelligente Autovervollständigung, welches durch ein Plugin erreicht wird. -1. Download IDEA, there is no difference between the Ultimate and Community editions +1. Lade IDEA herunter. Es gibt keinen Unterschied zwischen der Ultimate- und Community-Edition. ![](images/1.4.idea1.png?raw=true) -2. Install the Go plugin. Choose `File - Setting - Plugins`, then click `Browser repo`. +2. Installiere das Go-Plugin. Gehe zu `File - Setting - Plugins` und klicke dann auf `Browser repo`. ![](images/1.4.idea3.png?raw=true) -3. Search `golang`, double click `download and install` and wait for the download to complete. +3. Starte eine Suche mit `golang`, klicke doppelt auf `download and install` und warte, bis der Download abgeschlossen ist. ![](images/1.4.idea4.png?raw=true) - Click `Apply`, then restart. -4. Now you can create a Go project. + Klicke auf `Apply` und starte das Programm neu. + +4. Nun kannst Du ein neues Go-Projekt erstellen. ![](images/1.4.idea5.png?raw=true) - Input the position of your Go sdk in the next step -basically it's your $GOROOT. + Gib im nächsten Schritt den Speicherort Deines Go-SDK (***SDK steht für Software Developement Kit***) an - normalerweise handelt es sich hierbei um $GOROOT. -( ***See a [blog post](http://wuwen.org/tips-about-using-intellij-idea-and-go/) for setup and use IntelliJ IDEA with Go step by step *** ) +( ***Werfe einen Blick auf diesen [Blogartikel](http://wuwen.org/tips-about-using-intellij-idea-and-go/), welcher die Installation und Einrichtung von IntelliJ IDEA mit Go schrittweise erläutert.*** ) ## Links -- [Directory](preface.md) -- Previous section: [Go commands](01.3.md) -- Next section: [Summary](01.5.md) +- [Inhaltsverzeichnis](preface.md) +- Vorheriger Abschnitt: [Go Befehle](01.3.md) +- Nächster Abschnitt: [Zusammenfassung](01.5.md) diff --git a/de/01.5.md b/de/01.5.md index 6df9c420..7ebe15f9 100644 --- a/de/01.5.md +++ b/de/01.5.md @@ -1,9 +1,9 @@ -# 1.5 Summary +# 1.5 Zusammenfassung -In this chapter, we talked about how to install Go using three different methods including from source code, the standard package and via third-party tools. Then we showed you how to configure the Go development environment, mainly covering how to setup your `$GOPATH`. After that, we introduced some steps for compiling and deploying Go programs. We then covered Go commands, including the compile, install, format and test commands. Finally, there are many powerful tools to develop Go programs such as LiteIDE, Sublime Text, Vim, Emacs, Eclipse, IntelliJ IDEA, etc. You can choose any one you like exploring the world of Go. +In diesem Kapitel haben wir die Installation auf drei verschiedene Arten besprochen. Dies waren die manuelle Installation mit Hilfe des Quellcodes von Go, die offiziellen Ein-Klick-Installationen und durch Lösungen Dritter. Danach haben wir uns mit der Konfiguration der Go Entwicklungsumgebung auseinander gesetzt, welche hauptsächlich die Einrichtung Deines `$GOPATH` umfasst. Zudem habe ich Dir gezeigt, wie man Programme kompiliert und einsetzt. Des Weiteren hast Du die verschiedenen Terminal-Befehle zum Kompilieren, Installieren, Formatieren und Testen von Go kennengelernt. Zum Schluss hast Du Dir mächtige Entwicklungswerkzeuge wie LiteIDE, Sublime Text, Vim, Emacs, Eclipse, IntelliJ IDEA u.a. zu Nutze gemacht. Suche Dir eines aus, um die Welt von Go zu erforschen. ## Links -- [Directory](preface.md) -- Previous section: [Go development tools](01.4.md) -- Next chapter: [Go basic knowledge](02.0.md) +- [Inhaltsverzeichnis](preface.md) +- Vorheriger Abschnitt: [Go Entwicklungswerkzeuge](01.4.md) +- Nächstes Kapitel: [Grundlegendes Wissen zu Go](02.0.md)