@@ -214,7 +214,7 @@ module does not exist:
214
214
```
215
215
216
216
Exclusions only apply to builds of the current module. If the current module
217
- were required by a larger build, the exclusions would not apply.= For example,
217
+ were required by a larger build, the exclusions would not apply. For example,
218
218
an exclusion in rsc.io/quote's go.mod will not apply to our “hello, world”
219
219
build. This policy balances giving the authors of the current module almost
220
220
arbitrary control over their own build, without also subjecting them to almost
@@ -332,7 +332,7 @@ Let's write an interesting “hello, world” program. Create a directory outsid
332
332
your GOPATH/src tree and change into it:
333
333
334
334
```
335
- $ cd $HOME
335
+ $ cd /home/gopher
336
336
$ mkdir hello
337
337
$ cd hello
338
338
```
@@ -361,10 +361,13 @@ go: creating new go.mod: module github.com/you/hello
361
361
$ go build
362
362
go: finding rsc.io/quote v1.5.2
363
363
go: downloading rsc.io/quote v1.5.2
364
+ go: extracting rsc.io/quote v1.5.2
364
365
go: finding rsc.io/sampler v1.3.0
365
366
go: finding golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
366
367
go: downloading rsc.io/sampler v1.3.0
368
+ go: extracting rsc.io/sampler v1.3.0
367
369
go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
370
+ go: extracting golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
368
371
$ ./hello
369
372
Hello, world.
370
373
```
@@ -381,6 +384,8 @@ this case, the go build wrote a new go.mod:
381
384
$ cat go.mod
382
385
module github.com/you/hello
383
386
387
+ go 1.12
388
+
384
389
require rsc.io/quote v1.5.2
385
390
```
386
391
@@ -443,9 +448,12 @@ Let's upgrade golang.org/x/text first:
443
448
$ go get golang.org/x/text
444
449
go: finding golang.org/x/text v0.3.0
445
450
go: downloading golang.org/x/text v0.3.0
451
+ go: extracting golang.org/x/text v0.3.0
446
452
$ cat go.mod
447
453
module github.com/you/hello
448
454
455
+ go 1.12
456
+
449
457
require (
450
458
golang.org/x/text v0.3.0 // indirect
451
459
rsc.io/quote v1.5.2
@@ -469,7 +477,7 @@ created:
469
477
```
470
478
$ go test github.com/you/hello rsc.io/quote
471
479
? github.com/you/hello [no test files]
472
- ok rsc.io/quote 0.002s
480
+ ok rsc.io/quote 0.003s
473
481
```
474
482
475
483
In the original go command, the package pattern all meant all packages found in
@@ -497,9 +505,12 @@ Another option is to upgrade all modules needed by the build, using go get -u:
497
505
$ go get -u
498
506
go: finding rsc.io/sampler v1.99.99
499
507
go: downloading rsc.io/sampler v1.99.99
508
+ go: extracting rsc.io/sampler v1.99.99
500
509
$ cat go.mod
501
510
module github.com/you/hello
502
511
512
+ go 1.12
513
+
503
514
require (
504
515
golang.org/x/text v0.3.0 // indirect
505
516
rsc.io/quote v1.5.2
@@ -550,6 +561,8 @@ Then use go get to ask for a specific version, like maybe v1.3.1:
550
561
$ cat go.mod
551
562
module github.com/you/hello
552
563
564
+ go 1.12
565
+
553
566
require (
554
567
golang.org/x/text v0.3.0 // indirect
555
568
rsc.io/quote v1.5.2
@@ -558,11 +571,14 @@ require (
558
571
$ go get rsc.io/sampler@v1.3.1
559
572
go: finding rsc.io/sampler v1.3.1
560
573
go: downloading rsc.io/sampler v1.3.1
574
+ go: extracting rsc.io/sampler v1.3.1
561
575
$ go list -m
562
576
github.com/you/hello
563
577
$ cat go.mod
564
578
module github.com/you/hello
565
579
580
+ go 1.12
581
+
566
582
require (
567
583
golang.org/x/text v0.3.0 // indirect
568
584
rsc.io/quote v1.5.2
@@ -583,11 +599,14 @@ go: finding rsc.io/quote v1.5.0
583
599
go: finding rsc.io/quote v1.4.0
584
600
go: finding rsc.io/sampler v1.0.0
585
601
go: downloading rsc.io/sampler v1.2.0
602
+ go: extracting rsc.io/sampler v1.2.0
586
603
$ go list -m
587
604
github.com/you/hello
588
605
$ cat go.mod
589
606
module github.com/you/hello
590
607
608
+ go 1.12
609
+
591
610
require (
592
611
golang.org/x/text v0.3.0 // indirect
593
612
rsc.io/quote v1.4.0
@@ -610,13 +629,17 @@ github.com/you/hello
610
629
$ cat go.mod
611
630
module github.com/you/hello
612
631
632
+ go 1.12
633
+
613
634
require (
614
635
golang.org/x/text v0.3.0 // indirect
615
636
rsc.io/quote v1.4.0
616
637
)
617
638
$ go test github.com/you/hello rsc.io/quote
618
639
go: downloading rsc.io/quote v1.4.0
640
+ go: extracting rsc.io/quote v1.4.0
619
641
go: downloading rsc.io/sampler v1.0.0
642
+ go: extracting rsc.io/sampler v1.0.0
620
643
? github.com/you/hello [no test files]
621
644
ok rsc.io/quote 0.002s
622
645
```
@@ -644,6 +667,8 @@ $ echo "** TODO: REMOVE THIS HACK; see https://github.com/golang/go/issues/26454
644
667
$ cat go.mod
645
668
module github.com/you/hello
646
669
670
+ go 1.12
671
+
647
672
require (
648
673
golang.org/x/text v0.3.0 // indirect
649
674
rsc.io/quote v1.5.2
@@ -659,6 +684,8 @@ github.com/you/hello
659
684
$ cat go.mod
660
685
module github.com/you/hello
661
686
687
+ go 1.12
688
+
662
689
require (
663
690
golang.org/x/text v0.3.0 // indirect
664
691
rsc.io/quote v1.5.2
@@ -673,7 +700,7 @@ $ quoteVersion=$(go list -m -f "{{.Version}}" rsc.io/quote)
673
700
```
674
701
675
702
Exclusions only apply to builds of the current module. If the current module
676
- were required by a larger build, the exclusions would not apply.= For example,
703
+ were required by a larger build, the exclusions would not apply. For example,
677
704
an exclusion in rsc.io/quote's go.mod will not apply to our “hello, world”
678
705
build. This policy balances giving the authors of the current module almost
679
706
arbitrary control over their own build, without also subjecting them to almost
@@ -732,29 +759,26 @@ fork github.com/rsc/quote and then push your change to your fork.
732
759
733
760
```
734
761
$ cd ../quote
735
- $ git remote add $GITHUB_ORG https://github.com/$GITHUB_ORG /quote-fork
762
+ $ git remote add go-modules-by-example https://github.com/go-modules-by-example /quote-fork
736
763
$ git commit -a -m 'my fork'
737
- [my_quote f8de482 ] my fork
764
+ [my_quote 1ab8a1a ] my fork
738
765
1 file changed, 1 insertion(+), 1 deletion(-)
739
- $ git push -q $GITHUB_ORG
740
- remote:
741
- remote: Create a pull request for 'my_quote' on GitHub by visiting:
742
- remote: https://github.com/go-modules-by-example/quote-fork/pull/new/my_quote
743
- remote:
766
+ $ git push -q go-modules-by-example
744
767
$ git tag v0.0.0-myfork
745
- $ git push -q $GITHUB_ORG v0.0.0-myfork
768
+ $ git push -q go-modules-by-example v0.0.0-myfork
746
769
```
747
770
748
771
Then you can use that as the replacement:
749
772
750
773
```
751
774
$ cd ../hello
752
- $ go mod edit -replace=rsc.io/quote=github.com/$GITHUB_ORG /quote-fork@v0.0.0-myfork
775
+ $ go mod edit -replace=rsc.io/quote=github.com/go-modules-by-example /quote-fork@v0.0.0-myfork
753
776
$ go list -m
754
777
go: finding github.com/go-modules-by-example/quote-fork v0.0.0-myfork
755
778
github.com/you/hello
756
779
$ go build
757
780
go: downloading github.com/go-modules-by-example/quote-fork v0.0.0-myfork
781
+ go: extracting github.com/go-modules-by-example/quote-fork v0.0.0-myfork
758
782
$ LANG=fr ./hello
759
783
Je peux manger du verre, ça ne me fait pas mal.
760
784
```
@@ -781,9 +805,9 @@ see vendor directories:
781
805
782
806
```
783
807
$ go tool nm hello | grep sampler.hello
784
- 585de8 D rsc.io/sampler.hello
808
+ 591d48 D rsc.io/sampler.hello
785
809
$ go tool nm vhello | grep sampler.hello
786
- 585de8 D rsc.io/sampler.hello
810
+ 591d48 D rsc.io/sampler.hello
787
811
```
788
812
789
813
Except for this difference, the builds should produce the same binaries. In
@@ -799,7 +823,7 @@ at the start of the title. More posts tomorrow. Thanks, and have fun!
799
823
### Version details
800
824
801
825
```
802
- go version go1.11.1 linux/amd64
826
+ go version go1.12 linux/amd64
803
827
```
804
828
805
829
<!-- END -->
0 commit comments