How to use build method of build Package

Best Syzkaller code snippet using build.build

mockdata.go

Source:mockdata.go Github

copy

Full Screen

...41/*42func NewMockGenesisBlock() *common.Block {43 file := file.Open()44}*/45// MockConfigGroupBuilder is used to build a mock ConfigGroup46type MockConfigGroupBuilder struct {47 Version uint6448 ModPolicy string49 OrdererAddress string50 MSPNames []string51 RootCA string52 Groups map[string]*common.ConfigGroup53 ChannelCapabilities []string54 ApplicationCapabilities []string55 OrdererCapabilities []string56 PolicyRefs []string57}58// MockConfigBlockBuilder is used to build a mock Chain configuration block59type MockConfigBlockBuilder struct {60 MockConfigGroupBuilder61 Index uint6462 LastConfigIndex uint6463}64// MockConfigUpdateEnvelopeBuilder builds a mock ConfigUpdateEnvelope65type MockConfigUpdateEnvelopeBuilder struct {66 MockConfigGroupBuilder67 ChannelID string68}69// Build creates a mock Chain configuration Block70func (b *MockConfigBlockBuilder) Build() *common.Block {71 return &common.Block{72 Header: &common.BlockHeader{73 Number: b.Index,74 },75 Metadata: b.buildBlockMetadata(),76 Data: &common.BlockData{77 Data: b.buildBlockEnvelopeBytes(),78 },79 }80}81// buildBlockMetadata builds BlockMetadata that contains an array of bytes in the following order:82// 0: SIGNATURES83// 1: LAST_CONFIG84// 2: TRANSACTIONS_FILTER85// 3: ORDERER86func (b *MockConfigBlockBuilder) buildBlockMetadata() *common.BlockMetadata {87 return &common.BlockMetadata{88 Metadata: [][]byte{89 b.buildSignaturesMetaDataBytes(),90 marshalOrPanic(b.buildLastConfigMetaData()),91 b.buildTransactionsFilterMetaDataBytes(),92 b.buildOrdererMetaDataBytes(),93 },94 }95}96func (b *MockConfigBlockBuilder) buildSignaturesMetaDataBytes() []byte {97 return []byte("test signatures")98}99func (b *MockConfigBlockBuilder) buildLastConfigMetaData() *common.Metadata {100 return &common.Metadata{101 Value: marshalOrPanic(b.buildLastConfig()),102 }103}104func (b *MockConfigBlockBuilder) buildTransactionsFilterMetaDataBytes() []byte {105 return []byte(ledger_util.TxValidationFlags{uint8(pp.TxValidationCode_VALID)})106}107func (b *MockConfigBlockBuilder) buildOrdererMetaDataBytes() []byte {108 // TODO: What's the structure of this?109 return []byte("orderer meta data")110}111func (b *MockConfigBlockBuilder) buildLastConfig() *common.LastConfig {112 return &common.LastConfig{Index: b.LastConfigIndex}113}114func (b *MockConfigBlockBuilder) buildBlockEnvelopeBytes() [][]byte {115 return [][]byte{marshalOrPanic(b.buildEnvelope())}116}117func (b *MockConfigBlockBuilder) buildEnvelope() *common.Envelope {118 return &common.Envelope{119 Payload: marshalOrPanic(b.buildPayload()),120 }121}122func (b *MockConfigBlockBuilder) buildPayload() *common.Payload {123 return &common.Payload{124 Header: b.buildHeader(),125 Data: marshalOrPanic(b.buildConfigEnvelope()),126 }127}128func (b *MockConfigBlockBuilder) buildHeader() *common.Header {129 return &common.Header{130 ChannelHeader: marshalOrPanic(b.buildChannelHeader()),131 }132}133func (b *MockConfigBlockBuilder) buildChannelHeader() *common.ChannelHeader {134 return &common.ChannelHeader{135 Type: int32(common.HeaderType_CONFIG),136 }137}138func (b *MockConfigBlockBuilder) buildConfigEnvelope() *common.ConfigEnvelope {139 return &common.ConfigEnvelope{Config: b.buildConfig()}140}141func (b *MockConfigBlockBuilder) buildConfig() *common.Config {142 return &common.Config{143 Sequence: 0,144 ChannelGroup: b.buildConfigGroup(),145 }146}147func (b *MockConfigGroupBuilder) buildConfigGroup() *common.ConfigGroup {148 return &common.ConfigGroup{149 Groups: map[string]*common.ConfigGroup{150 "Orderer": b.buildOrdererGroup(),151 "Application": b.buildApplicationGroup(),152 },153 Policies: map[string]*common.ConfigPolicy{154 "BlockValidation": b.buildBasicConfigPolicy(),155 "Writers": b.buildBasicConfigPolicy(),156 "Readers": b.buildBasicConfigPolicy(),157 "Admins": b.buildBasicConfigPolicy(),158 },159 Values: map[string]*common.ConfigValue{160 channelConfig.OrdererAddressesKey: b.buildOrdererAddressesConfigValue(),161 channelConfig.CapabilitiesKey: b.buildCapabilitiesConfigValue(b.ChannelCapabilities),162 },163 Version: b.Version,164 ModPolicy: b.ModPolicy,165 }166}167func (b *MockConfigGroupBuilder) buildOrdererAddressesConfigValue() *common.ConfigValue {168 return &common.ConfigValue{169 Version: b.Version,170 ModPolicy: b.ModPolicy,171 Value: marshalOrPanic(b.buildOrdererAddresses())}172}173func (b *MockConfigGroupBuilder) buildOrdererAddresses() *common.OrdererAddresses {174 return &common.OrdererAddresses{175 Addresses: []string{b.OrdererAddress},176 }177}178func (b *MockConfigGroupBuilder) buildOrdererGroup() *common.ConfigGroup {179 return &common.ConfigGroup{180 Groups: map[string]*common.ConfigGroup{181 "OrdererMSP": b.buildMSPGroup("OrdererMSP"),182 },183 Policies: map[string]*common.ConfigPolicy{184 "BlockValidation": b.buildBasicConfigPolicy(),185 "Writers": b.buildBasicConfigPolicy(),186 "Readers": b.buildBasicConfigPolicy(),187 "Admins": b.buildBasicConfigPolicy(),188 },189 Values: map[string]*common.ConfigValue{190 channelConfig.ConsensusTypeKey: b.buildConsensusTypeConfigValue(),191 channelConfig.BatchSizeKey: b.buildBatchSizeConfigValue(),192 channelConfig.BatchTimeoutKey: b.buildBatchTimeoutConfigValue(),193 channelConfig.ChannelRestrictionsKey: b.buildChannelRestrictionsConfigValue(),194 channelConfig.CapabilitiesKey: b.buildCapabilitiesConfigValue(b.OrdererCapabilities),195 channelConfig.KafkaBrokersKey: b.buildKafkaBrokersConfigValue(),196 },197 Version: b.Version,198 ModPolicy: b.ModPolicy,199 }200}201func (b *MockConfigGroupBuilder) buildMSPGroup(mspName string) *common.ConfigGroup {202 return &common.ConfigGroup{203 Groups: nil,204 Policies: map[string]*common.ConfigPolicy{205 "Admins": b.buildSignatureConfigPolicy(),206 "Writers": b.buildSignatureConfigPolicy(),207 "Readers": b.buildSignatureConfigPolicy(),208 },209 Values: map[string]*common.ConfigValue{210 channelConfig.MSPKey: b.buildMSPConfigValue(mspName),211 // TODO: More212 },213 Version: b.Version,214 ModPolicy: b.ModPolicy,215 }216}217func (b *MockConfigGroupBuilder) buildMSPConfigValue(name string) *common.ConfigValue {218 return &common.ConfigValue{219 Version: b.Version,220 ModPolicy: b.ModPolicy,221 Value: marshalOrPanic(b.buildMSPConfig(name))}222}223func (b *MockConfigGroupBuilder) buildBatchSizeConfigValue() *common.ConfigValue {224 return &common.ConfigValue{225 Version: b.Version,226 ModPolicy: b.ModPolicy,227 Value: marshalOrPanic(b.buildBatchSize())}228}229func (b *MockConfigGroupBuilder) buildConsensusTypeConfigValue() *common.ConfigValue {230 return &common.ConfigValue{231 Version: b.Version,232 ModPolicy: b.ModPolicy,233 Value: marshalOrPanic(b.buildConsensusType())}234}235func (b *MockConfigGroupBuilder) buildBatchTimeoutConfigValue() *common.ConfigValue {236 return &common.ConfigValue{237 Version: b.Version,238 ModPolicy: b.ModPolicy,239 Value: marshalOrPanic(b.buildBatchTimeout())}240}241func (b *MockConfigGroupBuilder) buildChannelRestrictionsConfigValue() *common.ConfigValue {242 return &common.ConfigValue{243 Version: b.Version,244 ModPolicy: b.ModPolicy,245 Value: marshalOrPanic(b.buildChannelRestrictions())}246}247func (b *MockConfigGroupBuilder) buildCapabilitiesConfigValue(capabilityNames []string) *common.ConfigValue {248 return &common.ConfigValue{249 Version: b.Version,250 ModPolicy: b.ModPolicy,251 Value: marshalOrPanic(b.buildCapabilities(capabilityNames))}252}253func (b *MockConfigGroupBuilder) buildKafkaBrokersConfigValue() *common.ConfigValue {254 return &common.ConfigValue{255 Version: b.Version,256 ModPolicy: b.ModPolicy,257 Value: marshalOrPanic(b.buildKafkaBrokers())}258}259func (b *MockConfigGroupBuilder) buildACLsConfigValue(policyRefs []string) *common.ConfigValue {260 return &common.ConfigValue{261 Version: b.Version,262 ModPolicy: b.ModPolicy,263 Value: marshalOrPanic(b.buildACLs(policyRefs))}264}265func (b *MockConfigGroupBuilder) buildBatchSize() *ab.BatchSize {266 return &ab.BatchSize{267 MaxMessageCount: 10,268 AbsoluteMaxBytes: 103809024,269 PreferredMaxBytes: 524288,270 }271}272func (b *MockConfigGroupBuilder) buildConsensusType() *ab.ConsensusType {273 return &ab.ConsensusType{274 Type: "kafka",275 State: ab.ConsensusType_STATE_NORMAL,276 }277}278func (b *MockConfigGroupBuilder) buildBatchTimeout() *ab.BatchTimeout {279 return &ab.BatchTimeout{280 Timeout: "123",281 }282}283func (b *MockConfigGroupBuilder) buildChannelRestrictions() *ab.ChannelRestrictions {284 return &ab.ChannelRestrictions{285 MaxCount: 200,286 }287}288func (b *MockConfigGroupBuilder) buildCapabilities(capabilityNames []string) *common.Capabilities {289 capabilities := make(map[string]*common.Capability)290 for _, capability := range capabilityNames {291 capabilities[capability] = &common.Capability{}292 }293 return &common.Capabilities{294 Capabilities: capabilities,295 }296}297func (b *MockConfigGroupBuilder) buildKafkaBrokers() *ab.KafkaBrokers {298 brokers := []string{"kafkabroker"}299 return &ab.KafkaBrokers{300 Brokers: brokers,301 }302}303func (b *MockConfigGroupBuilder) buildACLs(policyRefs []string) *pp.ACLs {304 acls := make(map[string]*pp.APIResource)305 for _, policyRef := range policyRefs {306 acls[policyRef] = &pp.APIResource{PolicyRef: policyRef}307 }308 return &pp.ACLs{309 Acls: acls,310 }311}312func (b *MockConfigGroupBuilder) buildMSPConfig(name string) *mb.MSPConfig {313 return &mb.MSPConfig{314 Type: 0,315 Config: marshalOrPanic(b.buildfabricMSPConfig(name)),316 }317}318func (b *MockConfigGroupBuilder) buildfabricMSPConfig(name string) *mb.FabricMSPConfig {319 return &mb.FabricMSPConfig{320 Name: name,321 Admins: [][]byte{},322 IntermediateCerts: [][]byte{},323 OrganizationalUnitIdentifiers: []*mb.FabricOUIdentifier{},324 RevocationList: [][]byte{},325 RootCerts: [][]byte{[]byte(b.RootCA)},326 SigningIdentity: nil,327 }328}329func (b *MockConfigGroupBuilder) buildBasicConfigPolicy() *common.ConfigPolicy {330 return &common.ConfigPolicy{331 Version: b.Version,332 ModPolicy: b.ModPolicy,333 Policy: &common.Policy{},334 }335}336func (b *MockConfigGroupBuilder) buildSignatureConfigPolicy() *common.ConfigPolicy {337 return &common.ConfigPolicy{338 Version: b.Version,339 ModPolicy: b.ModPolicy,340 Policy: b.buildSignaturePolicy(),341 }342}343func (b *MockConfigGroupBuilder) buildSignaturePolicy() *common.Policy {344 return &common.Policy{345 Type: int32(common.Policy_SIGNATURE),346 Value: marshalOrPanic(b.buildSignedBySignaturePolicy()),347 }348}349func (b *MockConfigGroupBuilder) buildSignedBySignaturePolicy() *common.SignaturePolicy {350 return &common.SignaturePolicy{351 Type: &common.SignaturePolicy_SignedBy{352 SignedBy: 0,353 },354 }355}356func (b *MockConfigGroupBuilder) buildApplicationGroup() *common.ConfigGroup {357 groups := make(map[string]*common.ConfigGroup)358 for _, name := range b.MSPNames {359 groups[name] = b.buildMSPGroup(name)360 }361 return &common.ConfigGroup{362 Groups: groups,363 Policies: map[string]*common.ConfigPolicy{364 "Admins": b.buildSignatureConfigPolicy(),365 "Writers": b.buildSignatureConfigPolicy(),366 "Readers": b.buildSignatureConfigPolicy(),367 },368 Values: map[string]*common.ConfigValue{369 channelConfig.CapabilitiesKey: b.buildCapabilitiesConfigValue(b.ApplicationCapabilities),370 channelConfig.ACLsKey: b.buildACLsConfigValue(b.PolicyRefs),371 },372 Version: b.Version,373 ModPolicy: b.ModPolicy,374 }375}376// Build builds an Envelope that contains a mock ConfigUpdateEnvelope377func (b *MockConfigUpdateEnvelopeBuilder) Build() *common.Envelope {378 return &common.Envelope{379 Payload: marshalOrPanic(b.buildPayload()),380 }381}382// BuildBytes builds an Envelope that contains a mock ConfigUpdateEnvelope and returns the marshaled bytes383func (b *MockConfigUpdateEnvelopeBuilder) BuildBytes() []byte {384 return marshalOrPanic(b.Build())385}386func (b *MockConfigUpdateEnvelopeBuilder) buildPayload() *common.Payload {387 return &common.Payload{388 Header: b.buildHeader(),389 Data: marshalOrPanic(b.buildConfigUpdateEnvelope()),390 }391}392func (b *MockConfigUpdateEnvelopeBuilder) buildHeader() *common.Header {393 return &common.Header{394 ChannelHeader: marshalOrPanic(&common.ChannelHeader{395 Type: int32(common.HeaderType_CONFIG_UPDATE)},396 ),397 }398}399func (b *MockConfigUpdateEnvelopeBuilder) buildConfigUpdateEnvelope() *common.ConfigUpdateEnvelope {400 return &common.ConfigUpdateEnvelope{401 ConfigUpdate: marshalOrPanic(b.buildConfigUpdate()),402 Signatures: nil,403 }404}405func (b *MockConfigUpdateEnvelopeBuilder) buildConfigUpdate() *common.ConfigUpdate {406 return &common.ConfigUpdate{407 ChannelId: b.ChannelID,408 ReadSet: b.buildConfigGroup(),409 WriteSet: b.buildConfigGroup(),410 }411}412// BuildConfigUpdateBytes builds an mock ConfigUpdate returns the marshaled bytes413func (b *MockConfigUpdateEnvelopeBuilder) BuildConfigUpdateBytes() []byte {414 return marshalOrPanic(b.buildConfigUpdate())415}416// marshalOrPanic serializes a protobuf message and panics if this operation fails.417func marshalOrPanic(pb proto.Message) []byte {418 data, err := proto.Marshal(pb)419 if err != nil {420 panic(err)421 }422 return data423}424// CreateBlockWithCCEvent creates a mock block425func CreateBlockWithCCEvent(events *pp.ChaincodeEvent, txID string,426 channelID string) (*common.Block, error) {427 return CreateBlockWithCCEventAndTxStatus(events, txID, channelID, pp.TxValidationCode_VALID)428}...

Full Screen

Full Screen

buildtag.go

Source:buildtag.go Github

copy

Full Screen

1// Copyright 2013 The Go Authors. All rights reserved.2// Use of this source code is governed by a BSD-style3// license that can be found in the LICENSE file.4//go:build go1.165// +build go1.166// Package buildtag defines an Analyzer that checks build tags.7package buildtag8import (9 "go/ast"10 "go/build/constraint"11 "go/parser"12 "go/token"13 "strings"14 "unicode"15 "golang.org/x/tools/go/analysis"16 "golang.org/x/tools/go/analysis/passes/internal/analysisutil"17)18const Doc = "check that +build tags are well-formed and correctly located"19var Analyzer = &analysis.Analyzer{20 Name: "buildtag",21 Doc: Doc,22 Run: runBuildTag,23}24func runBuildTag(pass *analysis.Pass) (interface{}, error) {25 for _, f := range pass.Files {26 checkGoFile(pass, f)27 }28 for _, name := range pass.OtherFiles {29 if err := checkOtherFile(pass, name); err != nil {30 return nil, err31 }32 }33 for _, name := range pass.IgnoredFiles {34 if strings.HasSuffix(name, ".go") {35 f, err := parser.ParseFile(pass.Fset, name, nil, parser.ParseComments)36 if err != nil {37 // Not valid Go source code - not our job to diagnose, so ignore.38 return nil, nil39 }40 checkGoFile(pass, f)41 } else {42 if err := checkOtherFile(pass, name); err != nil {43 return nil, err44 }45 }46 }47 return nil, nil48}49func checkGoFile(pass *analysis.Pass, f *ast.File) {50 var check checker51 check.init(pass)52 defer check.finish()53 for _, group := range f.Comments {54 // A +build comment is ignored after or adjoining the package declaration.55 if group.End()+1 >= f.Package {56 check.plusBuildOK = false57 }58 // A //go:build comment is ignored after the package declaration59 // (but adjoining it is OK, in contrast to +build comments).60 if group.Pos() >= f.Package {61 check.goBuildOK = false62 }63 // Check each line of a //-comment.64 for _, c := range group.List {65 // "+build" is ignored within or after a /*...*/ comment.66 if !strings.HasPrefix(c.Text, "//") {67 check.plusBuildOK = false68 }69 check.comment(c.Slash, c.Text)70 }71 }72}73func checkOtherFile(pass *analysis.Pass, filename string) error {74 var check checker75 check.init(pass)76 defer check.finish()77 // We cannot use the Go parser, since this may not be a Go source file.78 // Read the raw bytes instead.79 content, tf, err := analysisutil.ReadFile(pass.Fset, filename)80 if err != nil {81 return err82 }83 check.file(token.Pos(tf.Base()), string(content))84 return nil85}86type checker struct {87 pass *analysis.Pass88 plusBuildOK bool // "+build" lines still OK89 goBuildOK bool // "go:build" lines still OK90 crossCheck bool // cross-check go:build and +build lines when done reading file91 inStar bool // currently in a /* */ comment92 goBuildPos token.Pos // position of first go:build line found93 plusBuildPos token.Pos // position of first "+build" line found94 goBuild constraint.Expr // go:build constraint found95 plusBuild constraint.Expr // AND of +build constraints found96}97func (check *checker) init(pass *analysis.Pass) {98 check.pass = pass99 check.goBuildOK = true100 check.plusBuildOK = true101 check.crossCheck = true102}103func (check *checker) file(pos token.Pos, text string) {104 // Determine cutpoint where +build comments are no longer valid.105 // They are valid in leading // comments in the file followed by106 // a blank line.107 //108 // This must be done as a separate pass because of the109 // requirement that the comment be followed by a blank line.110 var plusBuildCutoff int111 fullText := text112 for text != "" {113 i := strings.Index(text, "\n")114 if i < 0 {115 i = len(text)116 } else {117 i++118 }119 offset := len(fullText) - len(text)120 line := text[:i]121 text = text[i:]122 line = strings.TrimSpace(line)123 if !strings.HasPrefix(line, "//") && line != "" {124 break125 }126 if line == "" {127 plusBuildCutoff = offset128 }129 }130 // Process each line.131 // Must stop once we hit goBuildOK == false132 text = fullText133 check.inStar = false134 for text != "" {135 i := strings.Index(text, "\n")136 if i < 0 {137 i = len(text)138 } else {139 i++140 }141 offset := len(fullText) - len(text)142 line := text[:i]143 text = text[i:]144 check.plusBuildOK = offset < plusBuildCutoff145 if strings.HasPrefix(line, "//") {146 check.comment(pos+token.Pos(offset), line)147 continue148 }149 // Keep looking for the point at which //go:build comments150 // stop being allowed. Skip over, cut out any /* */ comments.151 for {152 line = strings.TrimSpace(line)153 if check.inStar {154 i := strings.Index(line, "*/")155 if i < 0 {156 line = ""157 break158 }159 line = line[i+len("*/"):]160 check.inStar = false161 continue162 }163 if strings.HasPrefix(line, "/*") {164 check.inStar = true165 line = line[len("/*"):]166 continue167 }168 break169 }170 if line != "" {171 // Found non-comment non-blank line.172 // Ends space for valid //go:build comments,173 // but also ends the fraction of the file we can174 // reliably parse. From this point on we might175 // incorrectly flag "comments" inside multiline176 // string constants or anything else (this might177 // not even be a Go program). So stop.178 break179 }180 }181}182func (check *checker) comment(pos token.Pos, text string) {183 if strings.HasPrefix(text, "//") {184 if strings.Contains(text, "+build") {185 check.plusBuildLine(pos, text)186 }187 if strings.Contains(text, "//go:build") {188 check.goBuildLine(pos, text)189 }190 }191 if strings.HasPrefix(text, "/*") {192 if i := strings.Index(text, "\n"); i >= 0 {193 // multiline /* */ comment - process interior lines194 check.inStar = true195 i++196 pos += token.Pos(i)197 text = text[i:]198 for text != "" {199 i := strings.Index(text, "\n")200 if i < 0 {201 i = len(text)202 } else {203 i++204 }205 line := text[:i]206 if strings.HasPrefix(line, "//") {207 check.comment(pos, line)208 }209 pos += token.Pos(i)210 text = text[i:]211 }212 check.inStar = false213 }214 }215}216func (check *checker) goBuildLine(pos token.Pos, line string) {217 if !constraint.IsGoBuild(line) {218 if !strings.HasPrefix(line, "//go:build") && constraint.IsGoBuild("//"+strings.TrimSpace(line[len("//"):])) {219 check.pass.Reportf(pos, "malformed //go:build line (space between // and go:build)")220 }221 return222 }223 if !check.goBuildOK || check.inStar {224 check.pass.Reportf(pos, "misplaced //go:build comment")225 check.crossCheck = false226 return227 }228 if check.goBuildPos == token.NoPos {229 check.goBuildPos = pos230 } else {231 check.pass.Reportf(pos, "unexpected extra //go:build line")232 check.crossCheck = false233 }234 // testing hack: stop at // ERROR235 if i := strings.Index(line, " // ERROR "); i >= 0 {236 line = line[:i]237 }238 x, err := constraint.Parse(line)239 if err != nil {240 check.pass.Reportf(pos, "%v", err)241 check.crossCheck = false242 return243 }244 if check.goBuild == nil {245 check.goBuild = x246 }247}248func (check *checker) plusBuildLine(pos token.Pos, line string) {249 line = strings.TrimSpace(line)250 if !constraint.IsPlusBuild(line) {251 // Comment with +build but not at beginning.252 // Only report early in file.253 if check.plusBuildOK && !strings.HasPrefix(line, "// want") {254 check.pass.Reportf(pos, "possible malformed +build comment")255 }256 return257 }258 if !check.plusBuildOK { // inStar implies !plusBuildOK259 check.pass.Reportf(pos, "misplaced +build comment")260 check.crossCheck = false261 }262 if check.plusBuildPos == token.NoPos {263 check.plusBuildPos = pos264 }265 // testing hack: stop at // ERROR266 if i := strings.Index(line, " // ERROR "); i >= 0 {267 line = line[:i]268 }269 fields := strings.Fields(line[len("//"):])270 // IsPlusBuildConstraint check above implies fields[0] == "+build"271 for _, arg := range fields[1:] {272 for _, elem := range strings.Split(arg, ",") {273 if strings.HasPrefix(elem, "!!") {274 check.pass.Reportf(pos, "invalid double negative in build constraint: %s", arg)275 check.crossCheck = false276 continue277 }278 elem = strings.TrimPrefix(elem, "!")279 for _, c := range elem {280 if !unicode.IsLetter(c) && !unicode.IsDigit(c) && c != '_' && c != '.' {281 check.pass.Reportf(pos, "invalid non-alphanumeric build constraint: %s", arg)282 check.crossCheck = false283 break284 }285 }286 }287 }288 if check.crossCheck {289 y, err := constraint.Parse(line)290 if err != nil {291 // Should never happen - constraint.Parse never rejects a // +build line.292 // Also, we just checked the syntax above.293 // Even so, report.294 check.pass.Reportf(pos, "%v", err)295 check.crossCheck = false296 return297 }298 if check.plusBuild == nil {299 check.plusBuild = y300 } else {301 check.plusBuild = &constraint.AndExpr{X: check.plusBuild, Y: y}302 }303 }304}305func (check *checker) finish() {306 if !check.crossCheck || check.plusBuildPos == token.NoPos || check.goBuildPos == token.NoPos {307 return308 }309 // Have both //go:build and // +build,310 // with no errors found (crossCheck still true).311 // Check they match.312 var want constraint.Expr313 lines, err := constraint.PlusBuildLines(check.goBuild)314 if err != nil {315 check.pass.Reportf(check.goBuildPos, "%v", err)316 return317 }318 for _, line := range lines {319 y, err := constraint.Parse(line)320 if err != nil {321 // Definitely should not happen, but not the user's fault.322 // Do not report.323 return324 }325 if want == nil {326 want = y327 } else {328 want = &constraint.AndExpr{X: want, Y: y}329 }330 }331 if want.String() != check.plusBuild.String() {332 check.pass.Reportf(check.plusBuildPos, "+build lines do not match //go:build condition")333 return334 }335}...

Full Screen

Full Screen

buildorder.go

Source:buildorder.go Github

copy

Full Screen

1package state2import (3 "groovin.dev/inv-api/pkg/models"4)5// Get all build orders6func GetBuildOrders(s *StateManager) []models.BuildOrder {7 // Return all build orders8 return s.GetBuildOrders()9}10// Get build order by ID11func GetBuildOrder(s *StateManager, id int) models.BuildOrder {12 // Get the build orders from the state manager13 buildOrders := s.GetBuildOrders()14 // Loop through build orders15 for _, buildOrder := range buildOrders {16 // If build order ID matches17 if buildOrder.ID == id {18 // Return build order19 return buildOrder20 }21 }22 // Return empty build order23 return models.BuildOrder{}24}25// Create build order26func CreateBuildOrder(s *StateManager, buildOrder models.BuildOrder) models.BuildOrder {27 // Get the build orders from the state manager28 buildOrders := s.GetBuildOrders()29 // Add build order to array30 buildOrders = append(buildOrders, buildOrder)31 // Return build order32 return buildOrder33}34// Update build order35func UpdateBuildOrder(s *StateManager, id int, buildOrder models.BuildOrder) models.BuildOrder {36 // Get the build orders from the state manager37 buildOrders := s.GetBuildOrders()38 // Loop through build orders39 for i, bo := range buildOrders {40 // If build order ID matches41 if bo.ID == id {42 // Update build order43 buildOrders[i] = buildOrder44 // Return build order45 return buildOrder46 }47 }48 // Return empty build order49 return models.BuildOrder{}50}51// Delete build order52func DeleteBuildOrder(s *StateManager, id int) models.BuildOrder {53 // Get the build orders from the state manager54 buildOrders := s.GetBuildOrders()55 // Loop through build orders56 for i, bo := range buildOrders {57 // If build order ID matches58 if bo.ID == id {59 // Delete build order60 buildOrders = append(buildOrders[:i], buildOrders[i+1:]...)61 // Return build order62 return bo63 }64 }65 // Return empty build order66 return models.BuildOrder{}67}...

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 b.build()4}5import (6func main() {7 b.build()8}9import (10func main() {11 b.build()12}13import (14func main() {15 b.build()16}17import (18func main() {19 b.build()20}21import (22func main() {23 b.build()24}25import (26func main() {27 b.build()28}29import (30func main() {31 b.build()32}33import (34func main() {35 b.build()36}37import (38func main() {39 b.build()40}41import (42func main() {43 b.build()44}45import (46func main() {47 b.build()48}49import (50func main() {51 b.build()52}53import

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 b := new(build)4 b.build()5}6import (7func main() {8 b := new(build)9 b.build()10}11import (12func main() {13 b := new(build)14 b.build()15}16import (17func main() {18 b := new(build)19 b.build()20}21import (22func main() {23 b := new(build)24 b.build()25}26import (27func main() {28 b := new(build)29 b.build()30}31import (32func main() {33 b := new(build)34 b.build()35}36import (37func main() {38 b := new(build)39 b.build()40}41import (42func main() {43 b := new(build)44 b.build()45}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1func main() {2 b.build()3}4func main() {5 b.build()6}7func main() {8 b.build()9}10func main() {11 b.build()12}13func main() {14 b.build()15}16func main() {17 b.build()18}19func main() {20 b.build()21}22func main() {23 b.build()24}25func main() {26 b.build()27}28func main() {29 b.build()30}31func main() {32 b.build()33}34func main() {35 b.build()36}37func main() {38 b.build()39}40func main() {41 b.build()42}43func main() {44 b.build()45}46func main() {47 b.build()48}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 user, err := user.Current()4 if err != nil {5 fmt.Println(err)6 }7 path, err := os.Getwd()8 if err != nil {9 fmt.Println(err)10 }11 goVersion := runtime.Version()12 goPath := os.Getenv("GOPATH")13 goBin := os.Getenv("GOBIN")14 goRoot := os.Getenv("GOROOT")15 goHost := os.Getenv("GOHOSTOS")16 goHostArch := os.Getenv("GOHOSTARCH")17 goHostVersion := os.Getenv("GOHOSTVERSION")18 goHostRoot := os.Getenv("GOHOSTROOT")19 goHostUser := os.Getenv("GOHOSTUSER")20 goHostTmpDir := os.Getenv("GOTMPDIR")21 goHostCompiler := os.Getenv("GOEXE")22 goHostCompiler2 := os.Getenv("CC")23 goHostCompiler3 := os.Getenv("CXX")24 goHostCompiler4 := os.Getenv("CGO_ENABLED")25 goHostCompiler5 := os.Getenv("GOGCCFLAGS")26 goHostCompiler6 := os.Getenv("CGO_CFLAGS")27 goHostCompiler7 := os.Getenv("CGO_CXXFLAGS")28 goHostCompiler8 := os.Getenv("CGO_LDFLAGS")29 goHostCompiler9 := os.Getenv("PKG_CONFIG")30 goHostCompiler10 := os.Getenv("

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 fmt.Println("Hello, playground")4 fmt.Println(math.Pi)5 fmt.Println(math.Sqrt(2))6 fmt.Println(math.Cbrt(8))7 fmt.Println(math.Round(2.5))8 fmt.Println(math.Round(2.4))9 fmt.Println(math.Round(2.6))10 fmt.Println(math.RoundToEven(2.5))11 fmt.Println(math.RoundToEven(2.4))12 fmt.Println(math.RoundToEven(2.6))13 fmt.Println(math.RoundToEven(3.5))14 fmt.Println(math.RoundToEven(3.4))15 fmt.Println(math.RoundToEven(3.6))16 fmt.Println(math.RoundToEven(4.5))17 fmt.Println(math.RoundToEven(4.4))18 fmt.Println(math.RoundToEven(4.6))19}20import (21func main() {22 fmt.Println("Hello, playground")23 fmt.Println(math.Pi)24 fmt.Println(math.Sqrt(2))25 fmt.Println(math.Cbrt(8))26 fmt.Println(math.Round(2.5))27 fmt.Println(math.Round(2.4))28 fmt.Println(math.Round(2.6))29 fmt.Println(math.RoundToEven(2.5))30 fmt.Println(math.RoundToEven(2.4))31 fmt.Println(math.RoundToEven(2.6))32 fmt.Println(math.RoundToEven(3.5))33 fmt.Println(math.RoundToEven(3.4))34 fmt.Println(math.RoundToEven(3.6))35 fmt.Println(math.RoundToEven(4.5))36 fmt.Println(math.RoundToEven(4.4))

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2type build struct {3}4func (b *build) build() {5 cmd := exec.Command("go", "build", b.ProjectPath)6 err := cmd.Run()7 if err != nil {8 fmt.Println("Error in building project : ", err)9 }10}11func main() {12 projectName := strings.Split(projectPath, "/")13 b := build{ProjectPath: projectPath, ProjectName: projectName[len(projectName)-1]}14 b.build()15}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 b := Build{}4 b.Build()5}6type Build struct {7}8func (b Build) Build() {9 fmt.Println("Volume of the building is", volume)10}11func (b Build) Build1() {12 fmt.Println("Volume of the building is", volume)13}14func (b Build) Build2() {15 fmt.Println("Volume of the building is", volume)16}17func (b Build) Build3() {18 fmt.Println("Volume of the building is", volume)19}20func (b Build) Build4() {21 fmt.Println("Volume of the building is", volume)22}23func (b Build) Build5() {24 fmt.Println("Volume of the building is", volume)25}26func (b Build) Build6() {27 fmt.Println("Volume of the building is", volume)28}29func (b Build) Build7() {30 fmt.Println("Volume of the building is", volume)31}32func (b Build) Build8() {33 fmt.Println("Volume of the building is", volume)34}35func (b Build) Build9() {36 fmt.Println("Volume of the building is", volume)37}38func (b Build) Build10() {39 fmt.Println("Volume of the building is", volume)40}41func (b Build) Build11() {42 fmt.Println("Volume of the building is", volume)43}44func (b Build) Build12() {

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import (2func main() {3 b := new(build)4 b.build("path to file")5}6import (7type build struct {8}9func (b *build) build(path string) {10 fmt.Println("Building...")11}

Full Screen

Full Screen

build

Using AI Code Generation

copy

Full Screen

1import "fmt"2type build struct {3}4func (b build) build() {5 fmt.Println("Build Name:", b.name)6 fmt.Println("Build Location:", b.location)7 fmt.Println("Build Price:", b.price)8 fmt.Println("Build Area:", b.area)9}10func main() {11 b1 := build {12 }13 b1.build()14}15import "fmt"16type build struct {17}18func (b *build) build() {19}20func main() {21 b1 := build {22 }23 b1.build()24 fmt.Println("Build Name:", b1.name)25 fmt.Println("Build Location:", b1.location)26 fmt.Println("Build Price:", b1.price)27 fmt.Println("Build Area:", b1.area)28}29import "fmt"30type build struct {

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful