This should be familiar with the principle, to be able to write.
But now .....
Note that there is no main function to _test.go the end of the command go test-v
Package Mainimport ("Testing" "Net/http") const Checkmark = "ok!" Const BALLOTX = "error!" Func testdownload (t *testing. T) {URL: = "http://localhost:8000/test.html" StatusCode: = 200t. Log ("Given the need to test downloading content.") {T.LOGF ("\twhen checking \"%s\ "for status code \"%d\ "", URL, statusCode) {resp, err: = http. Get (URL) if err! = Nil {t.fatal ("\tshould is able to make the get call.", Ballotx, Err)}t.log ("\t\tshould is able to make T He Get call. ", checkmark) Defer resp. Body.close () If Resp. StatusCode = = StatusCode {T.LOGF ("\t\tshould receive a \"%d\ "status,%v", StatusCode, Checkmark)} else {T.errorf ("\t\tsho Uld receive a \ "%d\" status. %v%v ", StatusCode, Ballotx, resp. StatusCode)}}}}
Go Language base Unit Test example