@@ -266,6 +266,9 @@ type BuildOptions struct {
266
266
267
267
// ExperimentalWorkspaceModule opts a user into the experimental support
268
268
// for multi-module workspaces.
269
+ //
270
+ // Deprecated: this feature is deprecated and will be removed in a future
271
+ // version of gopls (https://go.dev/issue/55331).
269
272
ExperimentalWorkspaceModule bool `status:"experimental"`
270
273
271
274
// ExperimentalPackageCacheKey controls whether to use a coarser cache key
@@ -288,8 +291,10 @@ type BuildOptions struct {
288
291
289
292
// ExperimentalUseInvalidMetadata enables gopls to fall back on outdated
290
293
// package metadata to provide editor features if the go command fails to
291
- // load packages for some reason (like an invalid go.mod file). This will
292
- // eventually be the default behavior, and this setting will be removed.
294
+ // load packages for some reason (like an invalid go.mod file).
295
+ //
296
+ // Deprecated: this setting is deprecated and will be removed in a future
297
+ // version of gopls (https://go.dev/issue/55333).
293
298
ExperimentalUseInvalidMetadata bool `status:"experimental"`
294
299
}
295
300
@@ -425,6 +430,9 @@ type DiagnosticOptions struct {
425
430
// file system notifications.
426
431
//
427
432
// This option must be set to a valid duration string, for example `"100ms"`.
433
+ //
434
+ // Deprecated: this setting is deprecated and will be removed in a future
435
+ // version of gopls (https://go.dev/issue/55332)
428
436
ExperimentalWatchedFileDelay time.Duration `status:"experimental"`
429
437
}
430
438
@@ -865,15 +873,15 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
865
873
866
874
result := OptionResult {Name : name , Value : value }
867
875
if _ , ok := seen [name ]; ok {
868
- result .errorf ("duplicate configuration for %s" , name )
876
+ result .parseErrorf ("duplicate configuration for %s" , name )
869
877
}
870
878
seen [name ] = struct {}{}
871
879
872
880
switch name {
873
881
case "env" :
874
882
menv , ok := value .(map [string ]interface {})
875
883
if ! ok {
876
- result .errorf ("invalid type %T, expect map" , value )
884
+ result .parseErrorf ("invalid type %T, expect map" , value )
877
885
break
878
886
}
879
887
if o .Env == nil {
@@ -886,7 +894,7 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
886
894
case "buildFlags" :
887
895
iflags , ok := value .([]interface {})
888
896
if ! ok {
889
- result .errorf ("invalid type %T, expect list" , value )
897
+ result .parseErrorf ("invalid type %T, expect list" , value )
890
898
break
891
899
}
892
900
flags := make ([]string , 0 , len (iflags ))
@@ -897,14 +905,14 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
897
905
case "directoryFilters" :
898
906
ifilters , ok := value .([]interface {})
899
907
if ! ok {
900
- result .errorf ("invalid type %T, expect list" , value )
908
+ result .parseErrorf ("invalid type %T, expect list" , value )
901
909
break
902
910
}
903
911
var filters []string
904
912
for _ , ifilter := range ifilters {
905
913
filter , err := validateDirectoryFilter (fmt .Sprintf ("%v" , ifilter ))
906
914
if err != nil {
907
- result .errorf ( err . Error () )
915
+ result .parseErrorf ( "%v" , err )
908
916
return result
909
917
}
910
918
filters = append (filters , strings .TrimRight (filepath .FromSlash (filter ), "/" ))
@@ -1048,7 +1056,12 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
1048
1056
case "experimentalPostfixCompletions" :
1049
1057
result .setBool (& o .ExperimentalPostfixCompletions )
1050
1058
1051
- case "experimentalWorkspaceModule" : // TODO(rfindley): suggest go.work on go1.18+
1059
+ case "experimentalWorkspaceModule" :
1060
+ const msg = "The experimentalWorkspaceModule feature has been replaced by go workspaces, " +
1061
+ "and will be removed in a future version of gopls (https://go.dev/issue/55331). " +
1062
+ "Please see https://github.com/golang/tools/blob/master/gopls/doc/workspace.md " +
1063
+ "for information on setting up multi-module workspaces using go.work files."
1064
+ result .softErrorf (msg )
1052
1065
result .setBool (& o .ExperimentalWorkspaceModule )
1053
1066
1054
1067
case "experimentalTemplateSupport" : // TODO(pjw): remove after June 2022
@@ -1067,14 +1080,18 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
1067
1080
o .TemplateExtensions = nil
1068
1081
break
1069
1082
}
1070
- result .errorf (fmt .Sprintf ("unexpected type %T not []string" , value ))
1071
- case "experimentalDiagnosticsDelay" , "diagnosticsDelay" :
1072
- if name == "experimentalDiagnosticsDelay" {
1073
- result .deprecated ("diagnosticsDelay" )
1074
- }
1083
+ result .parseErrorf ("unexpected type %T not []string" , value )
1084
+
1085
+ case "experimentalDiagnosticsDelay" :
1086
+ result .deprecated ("diagnosticsDelay" )
1087
+
1088
+ case "diagnosticsDelay" :
1075
1089
result .setDuration (& o .DiagnosticsDelay )
1076
1090
1077
1091
case "experimentalWatchedFileDelay" :
1092
+ const msg = "The experimentalWatchedFileDelay setting is deprecated, and will " +
1093
+ "be removed in a future version of gopls (https://go.dev/issue/55332)."
1094
+ result .softErrorf (msg )
1078
1095
result .setDuration (& o .ExperimentalWatchedFileDelay )
1079
1096
1080
1097
case "experimentalPackageCacheKey" :
@@ -1087,6 +1104,9 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
1087
1104
result .setBool (& o .AllowImplicitNetworkAccess )
1088
1105
1089
1106
case "experimentalUseInvalidMetadata" :
1107
+ const msg = "The experimentalUseInvalidMetadata setting is deprecated, and will be removed" +
1108
+ "in a future version of gopls (https://go.dev/issue/55333)."
1109
+ result .softErrorf (msg )
1090
1110
result .setBool (& o .ExperimentalUseInvalidMetadata )
1091
1111
1092
1112
case "allExperiments" :
@@ -1140,7 +1160,11 @@ func (o *Options) set(name string, value interface{}, seen map[string]struct{})
1140
1160
return result
1141
1161
}
1142
1162
1143
- func (r * OptionResult ) errorf (msg string , values ... interface {}) {
1163
+ // parseErrorf reports an error parsing the current configuration value.
1164
+ func (r * OptionResult ) parseErrorf (msg string , values ... interface {}) {
1165
+ if false {
1166
+ _ = fmt .Sprintf (msg , values ... ) // this causes vet to check this like printf
1167
+ }
1144
1168
prefix := fmt .Sprintf ("parsing setting %q: " , r .Name )
1145
1169
r .Error = fmt .Errorf (prefix + msg , values ... )
1146
1170
}
@@ -1154,6 +1178,16 @@ func (e *SoftError) Error() string {
1154
1178
return e .msg
1155
1179
}
1156
1180
1181
+ // softErrorf reports an error that does not affect the functionality of gopls
1182
+ // (a warning in the UI).
1183
+ // The formatted message will be shown to the user unmodified.
1184
+ func (r * OptionResult ) softErrorf (format string , values ... interface {}) {
1185
+ msg := fmt .Sprintf (format , values ... )
1186
+ r .Error = & SoftError {msg }
1187
+ }
1188
+
1189
+ // deprecated reports the current setting as deprecated. If 'replacement' is
1190
+ // non-nil, it is suggested to the user.
1157
1191
func (r * OptionResult ) deprecated (replacement string ) {
1158
1192
msg := fmt .Sprintf ("gopls setting %q is deprecated" , r .Name )
1159
1193
if replacement != "" {
@@ -1162,14 +1196,15 @@ func (r *OptionResult) deprecated(replacement string) {
1162
1196
r .Error = & SoftError {msg }
1163
1197
}
1164
1198
1199
+ // unexpected reports that the current setting is not known to gopls.
1165
1200
func (r * OptionResult ) unexpected () {
1166
1201
r .Error = fmt .Errorf ("unexpected gopls setting %q" , r .Name )
1167
1202
}
1168
1203
1169
1204
func (r * OptionResult ) asBool () (bool , bool ) {
1170
1205
b , ok := r .Value .(bool )
1171
1206
if ! ok {
1172
- r .errorf ("invalid type %T, expect bool" , r .Value )
1207
+ r .parseErrorf ("invalid type %T, expect bool" , r .Value )
1173
1208
return false , false
1174
1209
}
1175
1210
return b , true
@@ -1185,7 +1220,7 @@ func (r *OptionResult) setDuration(d *time.Duration) {
1185
1220
if v , ok := r .asString (); ok {
1186
1221
parsed , err := time .ParseDuration (v )
1187
1222
if err != nil {
1188
- r .errorf ("failed to parse duration %q: %v" , v , err )
1223
+ r .parseErrorf ("failed to parse duration %q: %v" , v , err )
1189
1224
return
1190
1225
}
1191
1226
* d = parsed
@@ -1217,18 +1252,18 @@ func (r *OptionResult) setAnnotationMap(bm *map[Annotation]bool) {
1217
1252
switch k {
1218
1253
case "noEscape" :
1219
1254
m [Escape ] = false
1220
- r .errorf (`"noEscape" is deprecated, set "Escape: false" instead` )
1255
+ r .parseErrorf (`"noEscape" is deprecated, set "Escape: false" instead` )
1221
1256
case "noNilcheck" :
1222
1257
m [Nil ] = false
1223
- r .errorf (`"noNilcheck" is deprecated, set "Nil: false" instead` )
1258
+ r .parseErrorf (`"noNilcheck" is deprecated, set "Nil: false" instead` )
1224
1259
case "noInline" :
1225
1260
m [Inline ] = false
1226
- r .errorf (`"noInline" is deprecated, set "Inline: false" instead` )
1261
+ r .parseErrorf (`"noInline" is deprecated, set "Inline: false" instead` )
1227
1262
case "noBounds" :
1228
1263
m [Bounds ] = false
1229
- r .errorf (`"noBounds" is deprecated, set "Bounds: false" instead` )
1264
+ r .parseErrorf (`"noBounds" is deprecated, set "Bounds: false" instead` )
1230
1265
default :
1231
- r .errorf ( err . Error () )
1266
+ r .parseErrorf ( "%v" , err )
1232
1267
}
1233
1268
continue
1234
1269
}
@@ -1240,15 +1275,15 @@ func (r *OptionResult) setAnnotationMap(bm *map[Annotation]bool) {
1240
1275
func (r * OptionResult ) asBoolMap () map [string ]bool {
1241
1276
all , ok := r .Value .(map [string ]interface {})
1242
1277
if ! ok {
1243
- r .errorf ("invalid type %T for map[string]bool option" , r .Value )
1278
+ r .parseErrorf ("invalid type %T for map[string]bool option" , r .Value )
1244
1279
return nil
1245
1280
}
1246
1281
m := make (map [string ]bool )
1247
1282
for a , enabled := range all {
1248
1283
if enabled , ok := enabled .(bool ); ok {
1249
1284
m [a ] = enabled
1250
1285
} else {
1251
- r .errorf ("invalid type %T for map key %q" , enabled , a )
1286
+ r .parseErrorf ("invalid type %T for map key %q" , enabled , a )
1252
1287
return m
1253
1288
}
1254
1289
}
@@ -1258,7 +1293,7 @@ func (r *OptionResult) asBoolMap() map[string]bool {
1258
1293
func (r * OptionResult ) asString () (string , bool ) {
1259
1294
b , ok := r .Value .(string )
1260
1295
if ! ok {
1261
- r .errorf ("invalid type %T, expect string" , r .Value )
1296
+ r .parseErrorf ("invalid type %T, expect string" , r .Value )
1262
1297
return "" , false
1263
1298
}
1264
1299
return b , true
@@ -1271,7 +1306,7 @@ func (r *OptionResult) asOneOf(options ...string) (string, bool) {
1271
1306
}
1272
1307
s , err := asOneOf (s , options ... )
1273
1308
if err != nil {
1274
- r .errorf ( err . Error () )
1309
+ r .parseErrorf ( "%v" , err )
1275
1310
}
1276
1311
return s , err == nil
1277
1312
}
0 commit comments