The Go language provides an HTTP package that makes it easy to develop an HTTP interface. The following is the sample code:Package Webserverimport ("Encoding/json" "FMT" "Net/http" "Time") func webserverbase () {fmt. Println ("This is webserver base!") The first parameter is the interface name when the client initiates an HTTP request, and the second parameter is a func that is responsible for processing the request. http. Handlefunc ("/login", Logintask)//server to listen on the host address an
);//Print result "Name of the parent class: animal--sub-category: Cat"}}This is written in the Java programming idea: "When a dog object is transformed into a animal reference, any domain access operations will be parsed by the compiler and therefore not polymorphic"Talking about static methods: If a method is static, its behavior is not polymorphic: Package thinker; Public class Animal { public String name= "Animal"; Public Static void Fun (String name) { System.out.println ("I
Install fingerprint identification on X220/T530Ubuntu14.10/LinuxMint17.1
On Ubuntu, you can install fprint-demo and fingerprint-gui as the fingerprint recognition software for ThinkPad.
I tried fprint-demo, which can be used with the Ubuntu SYSTEM account, but the recognition effect is poor.
Fingerprint-gui runs as an independent fingerprint software, and the recognition effect is good. Therefore, finger
Bad2}Type Bad2 Interface {Listen to Bad1}
Null interface (Empty interface)The null interface is special, and it does not contain any methods:
Copy the Code code as follows:
interface{}
In the go language, all other data types implement an empty interface.
Copy the Code code as follows:
var v1 interface{} = 1var v2 interface{} = "abc"var v3 interface{} = struct{X int}{1}
If the function intends to receive any data type, the reference can be declared as interface{}. The most typical exam
This is a creation in
Article, where the information may have evolved or changed.
Some understanding after reading this article
1 io. Writer interface
Io. The writer interface is defined as follows
Package IO Type Writer interface { write (P []byte) (n int, err error)}//According to the features of the interface in go, all implemented the type of the Write method, we say it implements IO. Writer interface.
2 SOMEPKG.ABC type implements the Io.writer interface
Package Somepkgtype ABC
receive any data type, the reference can be declared as interface{}. The most typical example is the functions of the print and Fprint series in the standard library FMT package:
func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{})func Fprintln(w io.Writer, a ...interface{})func Print(a ...interface{}) (n int, err error)func Printf(format
This is a creation in
Article, where the information may have evolved or changed.
Exercise: HTTP Processing
Implement the following type, and define the Servehttp method on it. Register them in the Web server to process the specified path.
Type string stringtype struct struct { greeting string punct string who string}
For example, you can register a processing method using the following methods:
http. Handle ("/string", String ("I ' m a frayed knot.")) http. Handle ("/struct",
This is a creation in
Article, where the information may have evolved or changed.
Exercise: HTTP Processing
Implement the following type, and define the Servehttp method on it. Register them in the Web server to process the specified path.
Type string stringtype struct struct { greeting string punct string who string}
For example, you can register a processing method using the following methods:
http. Handle ("/string", String ("I ' m a frayed knot.")) http. Handle ("/struct",
, 2, 3, 5, 8 ...Write a fib class in which Fib (10) represents the first 10 elements of the sequence, printFib prints the first 10 elements of an array, and Len (fib ) Returns the number of numbers 10 correctly.Code Listing 1: (reference Code)You can use STR () to convert an integer list to a string.Class Fib (object):def __init__ (self, num):a, b, L = 0, 1, []For n in range (num):L.append (a)a, B = b, A + bSelf.numbers = Ldef __str__ (self):Return STR (self.numbers)__repr__ = __str__def __len__
the next data needs to be returned.IteratorIt can even represent an infinitely large stream of data, such as the whole natural number. Using list is never possible to store all natural numbers.SummaryAny object that can be used for for the loop is a Iterable type;All objects that can be used for next() functions are Iterator types, which represent a sequence of lazy computations;Collection data types such as list , dict ,, and str so on are Iterable not Iterator , however, you can iter() get an
Implement the following types and define Servehttp methods on them. Register them to handle specific paths in your Web server.Type string stringtype struct struct { greeting string punct string who string}For example, you should is able to register handlers using:http. Handle ("/string", String ("I ' m a frayed knot.")) http. Handle ("/struct", struct{"Hello", ":", "gophers!"})Package Mainimport ("net/http" "FMT") Type Stringstringtype Structstruct{GreetingstringpunctstringW.
I. Environment Description RHEL 6.6 + Oracle 11.2.0.4 storage replacement, need to add a new disk, replace the old storage disk, the following is the test steps. II. test process [[[emailprotected] ~]# cd/etc/udev[[emailprotected] udev]# lsmakedev.d rules.d udev.conf[[email protected] udev]# CD rules.d/[[emailprotected] rules.d]# ls55-usm.rules 60-pcmcia.rules 70- Persistent-net.rules 98-kexec.rules60-fprint-autosuspend.rules 60-raw.rules 90-alsa.rule
,
The rule is Write a little bit more than the interface, but it is also better understood, note 8th, even if we encountered errors while reading, but also should deal with the data already read, because these have read the data is correct, if not processed lost, the reading of the data is not complete.
"Go language Combat" reading notes, not to be continued, welcome to sweep code attention flysnow_org to the public or website http://www.flysnow.org/, the first time to see follow-up no
"var v3 interface{} = struct{ X int }{1}
If the function intends to receive any data type, the reference can be declared as interface{}. The most typical example is the functions of the print and Fprint series in the standard library FMT package:
func Fprint(w io.Writer, a ...interface{}) (n int, err error) func Fprintf(w io.Writer, format string, a ...interface{})func Fprintln(w io.Writer, a ...interface
This is a creation in
Article, where the information may have evolved or changed.
This program achieves LED blink in Raspberry Pi with Go lang.//This is the implemented with Hard-coding and uses only main Function.package mainimport ("FMT" "OS" "Time") Func main () {//Initialize GPIO25 FMT . Println ("Initialize GPIO25") fd, ERR: = OS. OpenFile ("/sys/class/gpio/export", OS. O_wronly|os. O_sync, 0666) if err! = Nil {fmt. PRINTLN ("Open/sys/class/gpio/export fails") FMT. PRINTLN (ERR) return} FMT
This is a creation in
Article, where the information may have evolved or changed.
Exercise: HTTP Processing
Implement the following type, and define the Servehttp method on it. Register them in the Web server to process the specified path.
Type string stringtype struct struct { greeting string punct string who string}
For example, you can register a processing method using the following methods:
http. Handle ("/string", String ("I ' m a frayed knot.")) http. Handle ("/struct",
This is a creation in
Article, where the information may have evolved or changed.
Exercise: HTTP Processing
Implement the following type, and define the Servehttp method on it. Register them in the Web server to process the specified path.
Type string stringtype struct struct { greeting string punct string who string}
For example, you can register a processing method using the following methods:
http. Handle ("/string", String ("I ' m a frayed knot.")) http. Handle ("/struct",
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.